1

我正在尝试(未成功)覆盖特定类的捆绑包。我想覆盖的类是:

Oro\Bundle\MagentoBundle\Entity\Repository\CustomerRepository

为此,我创建了我的捆绑包

namespace Kiwee\Bundle\MnhBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class MnhMagentoBundle extends Bundle {

    public function getParent() {
        return 'OroMagentoBundle';
    }
}

我添加了 bundles.yml

bundles:
    - Kiwee\Bundle\MnhBundle\MnhMagentoBundle

到目前为止,一切都很好.. 捆绑包已加载。现在,似乎我找不到任何关于如何覆盖上述类的工作示例。

我尝试创建一个与我要覆盖的类具有相同相对路径的文件,但它不起作用。

namespace Kiwee\Bundle\MnhBundle\Entity\Repository;

use Oro\Bundle\MagentoBundle\Entity\Repository\CustomerRepository as BaseCustomerRepository;

class CustomerRepository extends BaseCustomerRepository
{
    public function calculateLifetimeValue(Customer $customer)
    {
        // [... here is my custom logic for this method ...]

    }
}

我遇到的第一个问题是“客户”与原始类中的类型不同。第二个是,即使通过声明完整的类路径来修复它,这个方法也永远不会在原来的时候使用。有什么提示吗?

非常感谢

4

1 回答 1

0

只需将其覆盖为常规学说存储库即可。请参阅此答案https://stackoverflow.com/a/37486268/2119164它应该可以解决您的问题。

于 2017-07-04T15:18:39.230 回答