• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BaseController & __construct


I have a controller that extends BaseController.

I also need to execute some code in the controllers __construct method.

The __construct gets called before the initController function in the BaseController.

Is there a "2ndary" controller init that I can use that will get called after initController ?

PS. I don't want to start using Filters for this.

PHP Code:
class BaseController extends Controller
    public function initController()
echo 'basecontroller init<br/>';
// ..........

class Search extends BaseController
    public function __construct()
        echo 'search __construct<br/>';

search __construct
basecontroller init

You can create your own initController() in your Search class.

PHP Code:
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)

// Your code here


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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