1

I want to use dispatch function in our controller I want to secure my Url when customer purchase a product then they are able to use the URL other wise URL is redirect

My Code is

namespace StackExchange\Customer\Controller\Index;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Controller\ResultFactory; 

class Index extends \Magento\Framework\App\Action\Action
{
    protected $messageManager;

    public function dispatch()
    {
       echo "hiii";
    } 

    public function execute()
    {

    }

And the error is

Fatal error: Declaration of StackExchange\Customer\Controller\Index\Index::dispatch() must be compatible with Magento\Framework\App\Action\AbstractAction::dispatch(Magento\Framework\App\RequestInterface $request) in /home/magento2marketplace/app/code/StackExchange/Customer/Controller/Index/Index.php on line 96

1 Answer 1

1

Your dispatch method must be compatible with the your parent class dispatch method.

public function dispatch(\Magento\Framework\App\RequestInterface $request)
{
     // your code
     return parent::dispatch($request);
}

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.