Define a custom method in Doctrine\ORM\PersistentC

2019-06-22 05:43发布

I'm fetching data with a many-to-many relationship and I want to define acustom method. Is it possible (and how) to use something like:

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

1条回答
在下西门庆
2楼-- · 2019-06-22 06:12

It seems to be not implemented already.

See this Doctrine's JIRA issue : http://www.doctrine-project.org/jira/browse/DDC-547

Consider allowing custom PersistentCollection implementations

We should consider allowing the configuration of custom PersistentCollection implementations on a per-association basis. This could allow users to craft optimized (SQL) behavior for for some of their collections to improve performance without changing the domain model code.

For this, PersistentCollection needs to be designed for inheritance.

查看更多
登录 后发表回答