2017-04-10 45 views

回答

0

Mage静态方法不存在了,你将不得不使用依赖注入来获得你的助手实例,例如在你的模型:

<?php 
namespace Mycompany\Mymodule\Model; 
use Mycompany\Mymodule\Helper\Data; 
class Custom { 

    private $helper; 

    public function __construct(
     Data $helper 
    ) { 
     $this->helper = $helper; 
    } 

    public function myMethod() { 
     $this->helper->helperMethod(); 
    } 
} 

您可以使用块等同一系统..并为现有的助手,你想使用。

相关问题