0

I am keep getting this error with my code although I only followed their instructions.

<?php 

namespace Training\Test\App;

class FrontController extends \Magento\Framework\App\FrontController

{

protected $routerList;

protected $response;

protected $logger;

public function __construct(

    \Magento\Framework\App\RouterList $routerList,
    \Magento\Framework\App\Response\Http $response,
    \Psr\Log\LoggerInterface $logger)

{

    $this->routerList = $routerList;
    $this->response = $response;
    $this->logger = $logger;
}


public function dispatch(\Magento\Framework\App\RequestInterface $request)
{
    foreach($this->routerList as $router)
    {
        $this->logger->addDebug(get_class($router));
    }
    return parent::dispatch($request);
}


}

1 Answer 1

2

This problem appeared because you didn't execute parent constructor. Correct version of your code:

public function __construct(
    \Magento\Framework\App\RouterList $routerList,
    \Magento\Framework\App\Response\Http $response,
    \Psr\Log\LoggerInterface $logger)

{

    $this->routerList = $routerList;
    $this->response = $response;
    $this->logger = $logger;

    parent::__construct($routerList, $response);
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.