support namespace alias
This commit is contained in:
parent
1bd6e841bf
commit
7c754e495e
@ -1715,6 +1715,13 @@ class Parser
|
||||
$token = $this->lexer->token;
|
||||
$className = $token['value'];
|
||||
|
||||
if (strrpos($className, ':') !== false) {
|
||||
list($namespaceAlias, $simpleClassName) = explode(':', $className);
|
||||
|
||||
$className = $this->em->getConfiguration()
|
||||
->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
|
||||
}
|
||||
|
||||
$this->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
$args[] = $this->NewObjectArg();
|
||||
|
@ -153,6 +153,62 @@ class NewOperatorTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]);
|
||||
}
|
||||
|
||||
public function testShouldSupportFromEntityNamespaceAlias()
|
||||
{
|
||||
$dql = "
|
||||
SELECT
|
||||
new CmsUserDTO(u.name, e.email, a.city)
|
||||
FROM
|
||||
cms:CmsUser u
|
||||
JOIN
|
||||
u.email e
|
||||
JOIN
|
||||
u.address a
|
||||
ORDER BY
|
||||
u.name";
|
||||
|
||||
|
||||
$this->_em->getConfiguration()
|
||||
->addEntityNamespace('cms', 'Doctrine\Tests\Models\CMS');
|
||||
|
||||
$query = $this->_em->createQuery($dql);
|
||||
$result = $query->getResult();
|
||||
|
||||
$this->assertCount(3, $result);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]);
|
||||
}
|
||||
|
||||
public function testShouldSupportValueObjectNamespaceAlias()
|
||||
{
|
||||
$dql = "
|
||||
SELECT
|
||||
new cms:CmsUserDTO(u.name, e.email, a.city)
|
||||
FROM
|
||||
cms:CmsUser u
|
||||
JOIN
|
||||
u.email e
|
||||
JOIN
|
||||
u.address a
|
||||
ORDER BY
|
||||
u.name";
|
||||
|
||||
|
||||
$this->_em->getConfiguration()
|
||||
->addEntityNamespace('cms', 'Doctrine\Tests\Models\CMS');
|
||||
|
||||
$query = $this->_em->createQuery($dql);
|
||||
$result = $query->getResult();
|
||||
|
||||
$this->assertCount(3, $result);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]);
|
||||
}
|
||||
|
||||
public function testShouldSupportLiteralExpression()
|
||||
{
|
||||
$dql = "
|
||||
|
Loading…
Reference in New Issue
Block a user