• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
controller calling controller

#1
Calling controller from another controller causes problem some times in ci3 because of its singleton architecture. Is it safe in ci4?  Which  design patterns now ci4 use instead of singleton?
          Heart  love codeigniter Heart
          Learning  best  practices
     Rate my post if you found it helpfull
Reply

#2
It is safe, though a little bit of a pain due to the classes that are injected in the controller's constructor, but you could do something like:

Code:
$otherController = new App\Controllers\OtherController($this->request, $this->response, $this->logger);

$otherController->doSomething();

However, I don't think it's required. See this blog post for ways to handle "modules" (yes, there will be a write-up in the user guide soon). With the new autoloader you can easily use any class it can find, so you can split the logic into as many libraries, entities, repositories, whatever you want, and access it that way.
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.