我正在尝试(不成功(覆盖捆绑包的特定类。 我想覆盖的类是:
Oro\Bundle\MagentoBundle\Entity\Repository\CustomerRepository
为此,我创建了我的捆绑包
namespace KiweeBundleMnhBundle;
use SymfonyComponentHttpKernelBundleBundle;
class MnhMagentoBundle extends Bundle {
public function getParent() {
return 'OroMagentoBundle';
}
}
我添加了捆绑包.yml
bundles:
- KiweeBundleMnhBundleMnhMagentoBundle
到目前为止,一切顺利..捆绑包已加载。 现在,我似乎找不到任何关于如何覆盖上述类的工作示例。
我尝试创建一个与我要覆盖的类具有相同相对路径的文件,但它不起作用。
namespace KiweeBundleMnhBundleEntityRepository;
use OroBundleMagentoBundleEntityRepositoryCustomerRepository as BaseCustomerRepository;
class CustomerRepository extends BaseCustomerRepository
{
public function calculateLifetimeValue(Customer $customer)
{
// [... here is my custom logic for this method ...]
}
}
我遇到的第一个问题是"客户"与原始类中的类型不同。 第二个是,即使通过声明完整的类路径来修复它,此方法也永远不会在原始时使用。 有什么提示吗?
谢谢
只需将其覆盖为常规教义存储库即可。 请参阅此答案 https://stackoverflow.com/a/37486268/2119164 它应该可以解决您的问题。