在Doctrine\ORM\PersistentCollection中定义自定义方法

use*_*183 5 php doctrine doctrine-orm

我正在获取具有多对多关系的数据,并且我想定义acustom方法.有可能(以及如何)使用类似的东西:

$hotel = $entityManager->getRepository('Hotels')->findOneById(1);
$types = $hotel->getTypes(); //$types is instance of **Doctrine\ORM\PersistentCollection**
$types->myCustomFunction(); //do something
Run Code Online (Sandbox Code Playgroud)

小智 0

似乎还没有实施。

请参阅此 Doctrine 的 JIRA 问题:http://www.doctrine-project.org/jira/browse/DDC-547

考虑允许自定义 PersistentCollection 实现

我们应该考虑允许在每个关联的基础上配置自定义 PersistentCollection 实现。这可以允许用户为其某些集合设计优化的 (SQL) 行为,以提高性能,而无需更改域模型代码。

为此,需要将 PersistentCollection 设计为继承。