在Doctrine\ORM\PersistentCollection中定义自定义方法 [英] Define a custom method in Doctrine\ORM\PersistentCollection
问题描述
$ hotel = $ entityManager-> getRepository('Hotels') - > findOneById(1);
$ types = $ hotel-> getTypes(); // $ types是** Doctrine\ORM\PersistentCollection的实例**
$ types-> myCustomFunction(); //做某事
似乎没有实现。
看到这个Doctrine的JIRA问题: http://www.doctrine-project.org/jira/browse/DDC-547
考虑允许自定义PersistentCollection实现
我们应该考虑允许在每个关联的基础上配置自定义PersistentCollection实现。
这可以允许用户为一些集合提供优化的(SQL)行为,以提高性能,而无需更改域模型代码。
为此,PersistentCollection需要设计为继承。
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
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.
这篇关于在Doctrine\ORM\PersistentCollection中定义自定义方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!