. */ /** * ConditionalExpression = ConditionalTerm {"OR" ConditionalTerm} * * @package Doctrine * @subpackage Query * @author Guilherme Blanco * @author Janne Vanhala * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link http://www.phpdoctrine.org * @since 2.0 * @version $Revision$ */ class Doctrine_Query_Production_ConditionalExpression extends Doctrine_Query_Production { protected $_conditionalTerms = array(); public function syntax($paramHolder) { // ConditionalExpression = ConditionalTerm {"OR" ConditionalTerm} $this->_conditionalTerms[] = $this->AST('ConditionalTerm', $paramHolder); while ($this->_isNextToken(Doctrine_Query_Token::T_OR)) { $this->_parser->match(Doctrine_Query_Token::T_OR); $this->_conditionalTerms[] = $this->AST('ConditionalTerm', $paramHolder); } // Optimize depth instances in AST if (count($this->_conditionalTerms) == 1) { return $this->_conditionalTerms[0]; } } public function buildSql() { return implode(' OR ', $this->_mapConditionalTerms()); } protected function _mapConditionalTerms() { return array_map(array(&$this, '_mapConditionalTerm'), $this->_conditionalTerms); } protected function _mapConditionalTerm($value) { return $value->buildSql(); } /** * Visitor support. * * @param object $visitor */ public function accept($visitor) { foreach ($this->_conditionalTerms as $term) { $term->accept($visitor); } $visitor->visitConditionalExpression($this); } /* Getters */ public function getConditionalTerms() { return $this->_conditionalTerms; } }