如何在自定义模块中的Command中实例Magento\Customer\Model\AccountManagement
?
我试图创建一个重置所有客户密码的命令
答案 0 :(得分:0)
您可以在AccountManagementInterface
使用DI,就像从Magento's code获取的代码段一样:
class Command
{
public function __construct(
AccountManagementInterface $customerAccountManagement
) {
$this->customerAccountManagement = $customerAccountManagement;
}
public function whatever() {
$this->customerAccountManagement->initiatePasswordReset(
$email,
AccountManagement::EMAIL_RESET
);
}
}