1

This class Magento\Framework\App\Action\Action is deprecated:

  • What is the interface to be implemented in the controller action?
  • How should I implement the interface in the controller action?
  • What should the controller structure with the implemented interface look like?

Below is this warning that identifies with the implementation of the Action Interface.

The class VendorName\ModuleName\Controller\Routing\ControllerAction does not restrict processed HTTP methods by implementing a HttpMethod nameActionInterface

1
  • Action class with \Magento\Framework\App\Action\HttpGetActionInterface
  • In the example below you can see how it is implemented with the structure.

Example:

<?php
declare(strict_types=1);

namespace VendorName\ModuleName\Controller\Index;

use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Controller\Result\Forward;
use Magento\Framework\Controller\Result\ForwardFactory;

/**
 * Class Index
 */
class Index implements HttpGetActionInterface
{
    /**
     * @var ForwardFactory
     */
    private $forwardFactory;

    /**
     * Index constructor.
     * @param ForwardFactory $forwardFactory
     */
    public function __construct(
        ForwardFactory $forwardFactory
    ) {
        $this->forwardFactory = $forwardFactory;
    }

    /**
     * @inheritdoc
     */
    public function execute()
    {
        /** @var Forward $forward */
        $forward = $this->forwardFactory->create();
        return $forward->forward('defaultNoRoute');
    }
}

Here is the Magento documentation on Routing and Action Class (ActionInterface)

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.