Welcome Guest, Not a member yet? Register   Sign In
Loading helper before controller
#9

Is this a good way to control before and after actions in CI4?
PHP Code:
   private function beforeRequest()
    {
        echo "Before";
    }

    private function afterRequest()
    {
        echo "After";
    

And my initController looks like that;


PHP Code:
    public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
    {
        
                $this
->beforeRequest();
        
// Do Not Edit This Line
        
parent::initController($request$response$logger);

        
//--------------------------------------------------------------------
        // Preload any models, libraries, etc, here.
        //--------------------------------------------------------------------
        // E.g.:
                // $this->session = \Config\Services::session();
                $this->afterRequest();    
         
Reply


Messages In This Thread
Loading helper before controller - by Cyto5 - 08-27-2020, 11:03 AM
RE: Loading helper before controller - by Cyto5 - 08-27-2020, 01:18 PM
RE: Loading helper before controller - by Cyto5 - 08-27-2020, 01:35 PM
RE: Loading helper before controller - by Cyto5 - 08-27-2020, 02:59 PM
RE: Loading helper before controller - by someone - 10-01-2020, 04:31 AM
RE: Loading helper before controller - by someone - 10-01-2020, 11:39 PM
RE: Loading helper before controller - by MGatner - 10-03-2020, 08:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB