injitools /
cms-Inji
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace Inji; |
||||||
| 4 | /** |
||||||
| 5 | * Controller |
||||||
| 6 | * |
||||||
| 7 | * @author Alexey Krupskiy <[email protected]> |
||||||
| 8 | * @link http://inji.ru/ |
||||||
| 9 | * @copyright 2015 Alexey Krupskiy |
||||||
| 10 | * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
||||||
| 11 | */ |
||||||
| 12 | class Controller { |
||||||
| 13 | |||||||
| 14 | /** |
||||||
| 15 | * Storage of cur requested controller |
||||||
| 16 | * |
||||||
| 17 | * @var Controller |
||||||
| 18 | */ |
||||||
| 19 | public static $cur = null; |
||||||
| 20 | |||||||
| 21 | /** |
||||||
| 22 | * Requested params for method |
||||||
| 23 | * |
||||||
| 24 | * @var array |
||||||
| 25 | */ |
||||||
| 26 | public $params = []; |
||||||
| 27 | |||||||
| 28 | /** |
||||||
| 29 | * Path to controller dir |
||||||
| 30 | * |
||||||
| 31 | * @var string |
||||||
| 32 | */ |
||||||
| 33 | public $path = ''; |
||||||
| 34 | |||||||
| 35 | /** |
||||||
| 36 | * Requested action name |
||||||
| 37 | * |
||||||
| 38 | * @var string |
||||||
| 39 | */ |
||||||
| 40 | public $method = 'index'; |
||||||
| 41 | |||||||
| 42 | /** |
||||||
| 43 | * Module of this controller |
||||||
| 44 | * |
||||||
| 45 | * @var Module |
||||||
| 46 | */ |
||||||
| 47 | public $module = null; |
||||||
| 48 | |||||||
| 49 | /** |
||||||
| 50 | * This controller name |
||||||
| 51 | * |
||||||
| 52 | * @var string |
||||||
| 53 | */ |
||||||
| 54 | public $name = ''; |
||||||
| 55 | |||||||
| 56 | /** |
||||||
| 57 | * Flag of controller runing |
||||||
| 58 | * |
||||||
| 59 | * @var boolean |
||||||
| 60 | */ |
||||||
| 61 | public $run = false; |
||||||
| 62 | |||||||
| 63 | public $methodResolved = false; |
||||||
| 64 | |||||||
| 65 | /** |
||||||
| 66 | * Run controller |
||||||
| 67 | */ |
||||||
| 68 | public function run() { |
||||||
| 69 | !$this->methodResolved && $this->resolveMethod(); |
||||||
| 70 | if (!method_exists($this, $this->method . 'Action')) { |
||||||
| 71 | INJI_SYSTEM_ERROR('method not found', true); |
||||||
| 72 | } |
||||||
| 73 | if (!$this->checkAccess()) { |
||||||
| 74 | $msg = !empty($this->module->app->access->config['access']['accessTree'][App::$cur->type]['msg']) ? $this->module->app->access->config['access']['accessTree'][App::$cur->type]['msg'] : \I18n\Text::module('Access', 'noaccess'); |
||||||
|
0 ignored issues
–
show
The property
access does not exist on Inji\App. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||||||
| 75 | Tools::redirect($this->access->getDeniedRedirect(), $msg); |
||||||
|
0 ignored issues
–
show
The property
access does not exist on Inji\Controller. Since you implemented __get, consider adding a @property annotation.
Loading history...
The method
getDeniedRedirect() does not exist on Inji\Module. It seems like you code against a sub-type of Inji\Module such as Inji\Access or Inji\Db.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
The method
getDeniedRedirect() does not exist on null.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 76 | } |
||||||
| 77 | $this->run = true; |
||||||
| 78 | $result = call_user_func_array([$this, $this->method . 'Action'], $this->params); |
||||||
| 79 | if ($result && is_callable([$result, 'send'])) { |
||||||
| 80 | $result->send(); |
||||||
| 81 | } |
||||||
| 82 | } |
||||||
| 83 | |||||||
| 84 | public function resolveMethod() { |
||||||
| 85 | if ($this->methodResolved) { |
||||||
| 86 | return true; |
||||||
| 87 | } |
||||||
| 88 | if (!empty($this->params[0]) && method_exists($this, $this->params[0] . 'Action')) { |
||||||
| 89 | $this->method = $this->params[0]; |
||||||
| 90 | $this->params = array_slice($this->params, 1); |
||||||
| 91 | $this->methodResolved = true; |
||||||
| 92 | return true; |
||||||
| 93 | } |
||||||
| 94 | return false; |
||||||
| 95 | } |
||||||
| 96 | |||||||
| 97 | /** |
||||||
| 98 | * Reference to short access core modules |
||||||
| 99 | * |
||||||
| 100 | * @param $name |
||||||
| 101 | * @return Module|null |
||||||
| 102 | */ |
||||||
| 103 | public function __get($name) { |
||||||
| 104 | return App::$cur->__get($name); |
||||||
| 105 | } |
||||||
| 106 | |||||||
| 107 | /** |
||||||
| 108 | * Reference to short access core modules |
||||||
| 109 | * |
||||||
| 110 | * @param $name |
||||||
| 111 | * @param $params |
||||||
| 112 | * @return null|Module |
||||||
| 113 | */ |
||||||
| 114 | public function __call($name, $params) { |
||||||
| 115 | return App::$cur->__call($name, $params); |
||||||
| 116 | } |
||||||
| 117 | |||||||
| 118 | /** |
||||||
| 119 | * Check access to controller method |
||||||
| 120 | * |
||||||
| 121 | * @return boolean |
||||||
| 122 | */ |
||||||
| 123 | public function checkAccess() { |
||||||
| 124 | if ($this->module->app->access) { |
||||||
|
0 ignored issues
–
show
The property
access does not exist on Inji\App. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||||||
| 125 | return $this->module->app->access->checkAccess($this); |
||||||
|
0 ignored issues
–
show
The method
checkAccess() does not exist on Inji\Module. It seems like you code against a sub-type of Inji\Module such as Inji\Access or Inji\Db.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 126 | } |
||||||
| 127 | return true; |
||||||
| 128 | } |
||||||
| 129 | |||||||
| 130 | } |
||||||
| 131 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths