. */ /** * JoinVariableDeclaration ::= Join [IndexBy] * * @author Guilherme Blanco * @author Janne Vanhala * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link http://www.phpdoctrine.org * @since 1.0 * @version $Revision$ */ class Doctrine_ORM_Query_Parser_JoinVariableDeclaration extends Doctrine_ORM_Query_ParserRule { protected $_AST = null; public function syntax($paramHolder) { // JoinVariableDeclaration ::= Join [IndexBy] $this->_AST = $this->AST('JoinVariableDeclaration'); $this->_AST->setJoin($this->parse('Join', $paramHolder)); if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_INDEX)) { $this->_AST->setIndexBy($this->parse('IndexBy', $paramHolder)); } } public function semantical($paramHolder) { // If we have an INDEX BY JoinVariableDeclaration if ($this->_AST->getIndexby() !== null) { // Grab Join component alias $joinComponentAlias = $this->_AST->getJoin() ->getAliasIdentificationVariable()->getComponentAlias(); // Grab IndexBy component alias $indexComponentAlias = $this->_AST->getIndexBy() ->getSimpleStateFieldPathExpression()->getIdentificationVariable()->getComponentAlias(); // Check if we have same component being used in index if ($joinComponentAlias !== $indexComponentAlias) { $message = "Invalid aliasing. Cannot index by '" . $indexComponentAlias . "' inside '" . $joinComponentAlias . "' scope."; $this->_parser->semanticalError($message); } } // Return AST node return $this->_AST; } }