BaseController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Controllers;
  3. use CodeIgniter\Controller;
  4. use CodeIgniter\HTTP\CLIRequest;
  5. use CodeIgniter\HTTP\IncomingRequest;
  6. use CodeIgniter\HTTP\RequestInterface;
  7. use CodeIgniter\HTTP\ResponseInterface;
  8. use Psr\Log\LoggerInterface;
  9. /**
  10. * Class BaseController
  11. *
  12. * BaseController provides a convenient place for loading components
  13. * and performing functions that are needed by all your controllers.
  14. * Extend this class in any new controllers:
  15. * class Home extends BaseController
  16. *
  17. * For security be sure to declare any new methods as protected or private.
  18. */
  19. abstract class BaseController extends Controller
  20. {
  21. /**
  22. * Instance of the main Request object.
  23. *
  24. * @var CLIRequest|IncomingRequest
  25. */
  26. protected $request;
  27. /**
  28. * An array of helpers to be loaded automatically upon
  29. * class instantiation. These helpers will be available
  30. * to all other controllers that extend BaseController.
  31. *
  32. * @var list<string>
  33. */
  34. protected $helpers = [];
  35. /**
  36. * Be sure to declare properties for any property fetch you initialized.
  37. * The creation of dynamic property is deprecated in PHP 8.2.
  38. */
  39. // protected $session;
  40. /**
  41. * @return void
  42. */
  43. public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
  44. {
  45. // Do Not Edit This Line
  46. parent::initController($request, $response, $logger);
  47. // Preload any models, libraries, etc, here.
  48. // E.g.: $this->session = \Config\Services::session();
  49. }
  50. }