| 1 | <?php |
||
| 16 | abstract class AbstractAuthorizedApiController extends BaseController |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * Allow anonymous access to this controller. |
||
| 20 | * |
||
| 21 | * @var bool |
||
| 22 | */ |
||
| 23 | protected $allowAnonymous = true; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Initialize controller |
||
| 27 | */ |
||
| 28 | public function init() |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return bool |
||
| 39 | */ |
||
| 40 | private function authorizeApi() |
||
| 54 | } |
||
| 55 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: