【发布时间】:2015-10-30 12:38:50
【问题描述】:
我有 CustomRepository 扩展 Doctrine\ORM\EntityRepository 的类。该存储库与许多不同的实体相关联。
存储库中有一个返回关联实体的方法。
class CustomRepository extends \Doctrine\ORM\EntityRepository
{
function getEntity() { ... } // returns an instance of associated entity
}
/**
* @ORM\Entity(repositoryClass="CustomRepository")
*/
class EntityClass1 { ... }
/**
* @ORM\Entity(repositoryClass="CustomRepository")
*/
class EntityClass2 { ... }
$repo1 = $entityManager->getRepository('Entity1');
$entity1 = $repo1->getEntity(); // will return an instance of EntityClass1
$repo2 = $entityManager->getRepository('Entity2');
$entity2 = $repo1->getEntity(); // will return an instance of EntityClass2
我使用 Symfony 2 插件,它可以正确检测继承方法实体返回的类为find。
有没有办法通知插件该方法返回关联实体?
【问题讨论】:
标签: symfony doctrine-orm phpstorm