K
K
kasamara2019-07-04 22:16:16
Magento
kasamara, 2019-07-04 22:16:16

How to connect the controller from core to the local custom module model?

I need to create an object of the controller class and call its method in the module's custom file.
When I create a new object, I get errors like:

Fatal error: Uncaught TypeError: Argument 1 passed to Mage_Core_Controller_Varien_Action::__construct() must be an instance of Zend_Controller_Request_Abstract, none given, called in /app/code/local/Mementia/SefUrls/Model/Parser.php on line 69 and defined in /app/code/core/Mage/Core/Controller/Varien/Action.php:138 Stack trace: #0 /app/code/local/Mementia/SefUrls/Model/Parser.php(69): Mage_Core_Controller_Varien_Action->__construct() #1 /var/www/сайт/data/www/сайт.com.ua/app/code/local/Mementia/SefUrls/Controller/Router.php(29): Mementia_SefUrls_Model_Parser->parseFilterInformationFromRequest('rakovinu-i-mojk...', '1', Object(Mage_Core_Controller_Request_Http)) #2 /var/www/сайт/data/www/сайт.com.ua/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mementia_SefUrls_Controller_Router->match(Object(Mage_Core_Controller_Request_Http)) #3 /var/www/сайт/data/www/сайт.com.ua/app/code/c in /var/www/сайт/data/www/сайт.com.ua/app/code/core/Mage/Core/Controller/Varien/Action.php on line 138

How can I implement this?
Before creating the object, I took the following actions:
require_once Mage::getModuleDir('controllers', 'Mage_Cms') . DS . 'IndexController.php';
$notFoundController = new Mage_Cms_IndexController();
return $notFoundController->noRouteAction();

if(!class_exists('Mage_Cms_IndexController'))
 {
 require_once('Mage/Cms/controllers/IndexController.php');        
 }
 $notFoundController = new Mage_Cms_IndexController();
return $notFoundController->noRouteAction();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
imdeveloper, 2019-07-05
@link_web

You need to pass something like $this->getRequest() to your object's constructor. And yes, I think you're doing something wrong. what is the task?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question