0

I have install extension and I get the following error on frontend.

Fatal error: Declaration of Apptha\Airhotels\Controller\Index\Index::execute() must be compatible with Magento\Cms\Controller\Index\Index::execute($coreRoute = NULL) in

public_html/app/code/Apptha/Airhotels/Controller/Index/Index.php

on line 52.

<?php
/**
 * Apptha
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.apptha.com/LICENSE.txt
 *
 * ==============================================================
 *                 MAGENTO EDITION USAGE NOTICE
 * ==============================================================
 * This package designed for Magento COMMUNITY edition
 * Apptha does not guarantee correct work of this extension
 * on any other Magento edition except Magento COMMUNITY edition.
 * Apptha does not provide extension support in case of
 * incorrect edition usage.
 * ==============================================================
 *
 * @category    Apptha
 * @package     Apptha_Airhotels
 * @version     1.0.0
 * @author      Apptha Team <developers@contus.in>
 * @copyright   Copyright (c) 2017 Apptha. (http://www.apptha.com)
 * @license     http://www.apptha.com/LICENSE.txt
 *
 */
namespace Apptha\Airhotels\Controller\Index;


class Index extends \Magento\Cms\Controller\Index\Index
{
    public function execute(){

         $objectManager = \Magento\Framework\App\ObjectManager::getInstance ();
         //$airhotelsKey = $objectManager->get ( 'Apptha\Airhotels\Helper\Product' )->AirhotelsKey();
         $moduleEnableornot = $objectManager->get ( 'Apptha\Airhotels\Helper\Data' )->getEnableFrontend();

         if ($moduleEnableornot == 0) {
               /**
               * Notification Message
               */
           $msg = base64_decode('PGgzIHN0eWxlPSJmbG9hdDpsZWZ0O2NvbG9yOnJlZDttYXJnaW46IDMwMHB4IDQ3NXB4OyB3aWR0aDoyNiU7IiBpZD0idGl0bGUtdGV4dCI+RW5hYmxlIEFpcmhvdGVscyB0byB2aWV3IHRoZSB3ZWJzaXRlPC9oMz4=');

           $this->getResponse()->setBody ( $msg );
        } else {
              return  parent::execute();
         }
    }
}

Need Help please.

1
  • why you have declined the accepted answer? Nov 4, 2019 at 15:44

2 Answers 2

0

Replace your function name from public function execute() to public function execute($coreRoute = null)

Or replace your extended class to \Magento\Framework\App\Action\Action if you don't want to inherit \Magento\Cms\Controller\Index\Index Class

Hope this will help you

5
  • Hello, Thank you but I get this following error again.
    – Coriaas
    Nov 4, 2019 at 13:20
  • show me your error message Nov 4, 2019 at 13:21
  • Fatal error: Multiple access type modifiers are not allowed in /home/app/code/Apptha/Airhotels/Controller/Index/Index.php on line 35
    – Coriaas
    Nov 4, 2019 at 13:21
  • prntscr.com/ps9bfa
    – Coriaas
    Nov 4, 2019 at 13:21
  • can you update your question with updated code Nov 4, 2019 at 13:21
0
<?php
/**
 * Apptha
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.apptha.com/LICENSE.txt
 *
 * ==============================================================
 *                 MAGENTO EDITION USAGE NOTICE
 * ==============================================================
 * This package designed for Magento COMMUNITY edition
 * Apptha does not guarantee correct work of this extension
 * on any other Magento edition except Magento COMMUNITY edition.
 * Apptha does not provide extension support in case of
 * incorrect edition usage.
 * ==============================================================
 *
 * @category    Apptha
 * @package     Apptha_Airhotels
 * @version     1.0.0
 * @author      Apptha Team <developers@contus.in>
 * @copyright   Copyright (c) 2017 Apptha. (http://www.apptha.com)
 * @license     http://www.apptha.com/LICENSE.txt
 *
 */
namespace Apptha\Airhotels\Controller\Index;


class Index extends \Magento\Cms\Controller\Index\Index
{
    public public function execute($coreRoute = null){

         $objectManager = \Magento\Framework\App\ObjectManager::getInstance ();
         //$airhotelsKey = $objectManager->get ( 'Apptha\Airhotels\Helper\Product' )->AirhotelsKey();
         $moduleEnableornot = $objectManager->get ( 'Apptha\Airhotels\Helper\Data' )->getEnableFrontend();

         if ($moduleEnableornot == 0) {
               /**
               * Notification Message
               */
           $msg = base64_decode('PGgzIHN0eWxlPSJmbG9hdDpsZWZ0O2NvbG9yOnJlZDttYXJnaW46IDMwMHB4IDQ3NXB4OyB3aWR0aDoyNiU7IiBpZD0idGl0bGUtdGV4dCI+RW5hYmxlIEFpcmhvdGVscyB0byB2aWV3IHRoZSB3ZWJzaXRlPC9oMz4=');

           $this->getResponse()->setBody ( $msg );
        } else {
              return  parent::execute();
         }
    }
}
3
  • replae this line public public function execute($coreRoute = null) to public function execute($coreRoute = null){ Nov 4, 2019 at 13:26
  • Thank you Rakesh, The site is now available
    – Coriaas
    Nov 4, 2019 at 13:33
  • you most welcome. accept the answer if its works. Nov 4, 2019 at 13:33

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.