Symfony覆盖另一个包的存储库不会覆盖它

时间:2017-09-21 12:57:30

标签: symfony symfony-3.3

我想覆盖另一个包的实体和存储库

所以

我想覆盖

src/MyBundle/Entity/Product
src/MyBundle/Entity/ProductRepository

所以我创建了另一个包AppBundle

src/AppBundle/Entity/Product extends src/MyBundle/Entity/Product
src/AppBundle/Entity/ProductRepository extends src/MyBundle/Entity/ProductRepository

所以在AppBundle中我想添加一些属性,并且还想在ProductRepository中编写自定义查询。

所以

class AppBundle extends Bundle
{
    public function getParent()
    {
        return 'MyBundle';
    }
}

In my AppBundle entity i have specify repository of src/AppBundle/Entity/ProductRepository

我该怎么做?

 * @ORM\Entity(repositoryClass="MyBundle\Entity\ProductRepository")
 */
class Product extends Base
{
}

$ em-> getRepository('AppBundle:Product')提供了

的存储库
MyBundle\Entity\ProductRepository

0 个答案:

没有答案