magento 2 controller __construct错误

时间:2017-07-13 12:51:37

标签: magento magento2

我正在此控制器上发送帖子数据,以便进行测试 我在执行方法中添加了die,如下面的代码所示。

但即使我没有在构造函数

中使用任何参数,我也会遇到奇怪的错误

错误

base = df.loc[df.index[0], 'A'].minute
df.groupby(['B', 'C', pd.Grouper(freq='60T', key='A', base=base)]).describe()

我的代码

            1 exception(s):
            Exception #0 (Exception): Recoverable Error: Argument 1 passed to 
            Magento\Framework\App\Action\Action::__construct() must be an instance of Magento\Framework\App\Action\Context, none given, called in C:\wamp64\www\PG\app\code\Webkul\Marketplace\Controller\Account\Saveareainfo.php on line 30 and defined in C:\wamp64\www\PG\vendor\magento\framework\App\Action\Action.php on line 67

            Exception #0 (Exception): Recoverable Error: Argument 1 passed to Magento\Framework\App\Action\Action::__construct() must be an instance of Magento\Framework\App\Action\Context, none given, called in C:\wamp64\www\PG\app\code\Webkul\Marketplace\Controller\Account\Saveareainfo.php on line 30 and defined in C:\wamp64\www\PG\vendor\magento\framework\App\Action\Action.php on line 67
            #0 C:\wamp64\www\PG\vendor\magento\framework\App\Action\Action.php(67): Magento\Framework\App\ErrorHandler->handler(4096, 'Argument 1 pass...', 'C:\\wamp64\\www\\P...', 67, Array)
            #1 C:\wamp64\www\PG\app\code\Webkul\Marketplace\Controller\Account\Saveareainfo.php(30): Magento\Framework\App\Action\Action->__construct()
            #2 C:\wamp64\www\PG\var\generation\Webkul\Marketplace\Controller\Account\Saveareainfo\Interceptor.php(14): Webkul\Marketplace\Controller\Account\Saveareainfo->__construct(Object(Magento\Framework\App\Action\Context))
            #3 C:\wamp64\www\PG\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(93): Webkul\Marketplace\Controller\Account\Saveareainfo\Interceptor->__construct(Object(Magento\Framework\App\Action\Context))
            #4 C:\wamp64\www\PG\vendor\magento\framework\ObjectManager\Factory\Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Webkul\\Marketpl...', Array)
            #5 C:\wamp64\www\PG\vendor\magento\framework\ObjectManager\ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Compiled->create('Webkul\\Marketpl...', Array)
            #6 C:\wamp64\www\PG\vendor\magento\framework\App\ActionFactory.php(40): Magento\Framework\ObjectManager\ObjectManager->create('Webkul\\Marketpl...')
            #7 C:\wamp64\www\PG\vendor\magento\framework\App\Router\Base.php(300): Magento\Framework\App\ActionFactory->create('Webkul\\Marketpl...')
            #8 C:\wamp64\www\PG\vendor\magento\framework\App\Router\Base.php(161): Magento\Framework\App\Router\Base->matchAction(Object(Magento\Framework\App\Request\Http), Array)
            #9 C:\wamp64\www\PG\vendor\magento\framework\App\FrontController.php(50): Magento\Framework\App\Router\Base->match(Object(Magento\Framework\App\Request\Http))
            #10 C:\wamp64\www\PG\vendor\magento\framework\Interception\Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
            #11 C:\wamp64\www\PG\vendor\magento\framework\Interception\Chain\Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
            #12 C:\wamp64\www\PG\vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'requestPreproce...')
            #13 C:\wamp64\www\PG\vendor\magento\module-store\App\FrontController\Plugin\RequestPreprocessor.php(94): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
            #14 C:\wamp64\www\PG\vendor\magento\framework\Interception\Chain\Chain.php(67): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
            #15 C:\wamp64\www\PG\vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
            #16 C:\wamp64\www\PG\vendor\magento\framework\Module\Plugin\DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
            #17 C:\wamp64\www\PG\vendor\magento\framework\Interception\Chain\Chain.php(67): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
            #18 C:\wamp64\www\PG\vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
            #19 C:\wamp64\www\PG\vendor\magento\module-page-cache\Model\App\FrontController\BuiltinPlugin.php(68): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
            #20 C:\wamp64\www\PG\vendor\magento\framework\Interception\Chain\Chain.php(67): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
            #21 C:\wamp64\www\PG\vendor\magento\framework\Interception\Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
            #22 C:\wamp64\www\PG\vendor\magento\module-page-cache\Model\App\FrontController\VarnishPlugin.php(55): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
            #23 C:\wamp64\www\PG\vendor\magento\framework\Interception\Interceptor.php(142): Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
            #24 C:\wamp64\www\PG\var\generation\Magento\Framework\App\FrontController\Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
            #25 C:\wamp64\www\PG\vendor\magento\framework\App\Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
            #26 C:\wamp64\www\PG\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http->launch()
            #27 C:\wamp64\www\PG\index.php(40): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
            #28 {main}

1 个答案:

答案 0 :(得分:2)

__construct()方法必须是Magento\Framework\App\Action\Context的实例,但没有给出。它应该像

  /**
 * @param Context $context
 */
public function __construct(
    Context $context
) {
    parent::__construct($context);
}

注意:部署模块后,删除var / di和var / generation文件夹并重新编译。