0

I am trying to extend the \Magento\Framework\App\Action\HttpPostActionInterface class and my construct looks like this:

public function __construct(
    \Magento\Framework\App\Action\Context $context,
    \Magento\Framework\View\Result\PageFactory $pageFactory,
    \Magento\Framework\Message\ManagerInterface $messageManager,
    \Magento\Framework\HTTP\Client\Curl $curl,
    \Magento\Framework\File\UploaderFactory $uploaderFactory)
{
    $this->_curl = $curl;
    $this->messageManager = $messageManager;
    $this->_pageFactory = $pageFactory;
    $this->uploaderFactory = $uploaderFactory;
    return parent::__construct($context);
}

I am getting an error though on this line return parent::__construct($context);

Cannot use 'parent' in a class with no parent.

How else should I write the return line then?

3
  • What does your class definition look like, i.e. the part where you extend the HttpPostActionInterface class?
    – joeybab3
    Jun 30 at 17:36
  • class submitForm extends \Magento\Framework\App\Action\HttpPostActionInterface Jun 30 at 19:53
  • I see you are confusing this as an interface how do you extend it . you are using class to create an extension for an interface
    – nhungo duc
    Jul 1 at 4:39
0

You cannot extend \Magento\Framework\App\Action\HttpPostActionInterface because it's an interface. You can implement it - in this case parent constructor calling is impossible.

I guess you need to extend certain action class instead of general interface.

2
0

Instead of extending \Magento\Framework\App\Action\HttpPostActionInterface you implement it. Since this is an interface, you cannot extend

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.