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);
}


}
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);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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