1

I am facing an error while running command di:compile

This is my block file

<?php

namespace Company\Module\Block;

class Booking extends \Magento\Framework\View\Element\Template
{
    /**
     * Construct
     *
     * @param \Magento\Framework\View\Element\Template\Context $context
     * @param array $data
     */
    public function __construct(
        \Magento\Framework\View\Element\Template $context,
        array $data = []
    )
    {
        parent::__construct($context, $data);
       }

    /**
     * Get form action URL for POST booking request
     *
     * @return string
     */
    public function getFormAction()
    {
           
        return '/companymodule/index/booking';
    }
}

below is the error i am getting. can someone help me to figure things out

Company\Module\Block\Booking
                Incompatible argument type: Required type: \Magento\Framework\View\Element\Template\Context. Actual type: \Magento\Framework\View\Element\Template; File:
0

3 Answers 3

0

update your __counstruct function

use this one:

public function __construct(
    \Magento\Framework\View\Element\Template\Context $context,
    array $data = []
)
{
    parent::__construct($context, $data);
}

This should resolve the issue

3

remove the constructor method from your class. You don't need it if the only thing it does is to call the parent constructor.

1
  • Yes it does not require constructor. Good solution. +1 Commented Jun 18, 2020 at 9:53
0

this now this correct way. public function __construct( \Magento\Framework\View\Element\Template\Context $context, array $data = [] ) { parent::__construct($context, $data); }

thanks

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.