. */ /** * AbstractSchemaName ::= identifier * * @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_Parser_AbstractSchemaName extends Doctrine_Query_ParserRule { protected $_AST = null; public function syntax($paramHolder) { // AbstractSchemaName ::= identifier $this->_AST = $this->AST('AbstractSchemaName'); $this->_parser->match(Doctrine_Query_Token::T_IDENTIFIER); $this->_AST->setComponentName($this->_parser->token['value']); } public function semantical($paramHolder) { $componentName = $this->_AST->getComponentName(); // Check if we are dealing with a real Doctrine_Entity or not if ( ! $this->_isDoctrineEntity($componentName)) { $this->_parser->semanticalError( "Defined entity '" . $companyName . "' is not a valid Doctrine_Entity." ); } // Return AST node return $this->_AST; } protected function _isDoctrineEntity($componentName) { if (class_exists($componentName)) { $reflectionClass = new ReflectionClass($componentName); $dctrnEntityReflectionClass = new ReflectionClass('Doctrine_Entity'); return $reflectionClass->isSubclassOf($dctrnEntityReflectionClass); } return false; } }