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