This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace hipanel\modules\finance\helpers; |
||
| 4 | |||
| 5 | use hipanel\modules\finance\models\proxy\Resource; |
||
| 6 | use RuntimeException; |
||
| 7 | use Yii; |
||
| 8 | |||
| 9 | class ResourceConfigurator |
||
| 10 | { |
||
| 11 | private string $gridClassName; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 12 | |||
| 13 | private string $searchModelClassName; |
||
| 14 | |||
| 15 | private string $modelClassName; |
||
| 16 | |||
| 17 | private string $searchView; |
||
| 18 | |||
| 19 | private string $toObjectUrl; |
||
| 20 | |||
| 21 | private string $fullTypePrefix; |
||
| 22 | |||
| 23 | private string $resourceModelClassName; |
||
| 24 | |||
| 25 | private array $columns = []; |
||
| 26 | |||
| 27 | private static self $configurator; |
||
| 28 | |||
| 29 | protected function __construct() |
||
| 30 | { |
||
| 31 | } |
||
| 32 | |||
| 33 | public function getGridClassName(): string |
||
| 34 | { |
||
| 35 | return $this->gridClassName; |
||
| 36 | } |
||
| 37 | |||
| 38 | public function setGridClassName(string $gridClassName): self |
||
| 39 | { |
||
| 40 | $this->gridClassName = $gridClassName; |
||
| 41 | |||
| 42 | return $this; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function getSearchModelClassName(): string |
||
| 46 | { |
||
| 47 | return $this->searchModelClassName; |
||
| 48 | } |
||
| 49 | |||
| 50 | public function setSearchModelClassName(string $searchModelClassName): self |
||
| 51 | { |
||
| 52 | $this->searchModelClassName = $searchModelClassName; |
||
| 53 | |||
| 54 | return $this; |
||
| 55 | } |
||
| 56 | |||
| 57 | public function getModelClassName(): string |
||
| 58 | { |
||
| 59 | return $this->modelClassName; |
||
| 60 | } |
||
| 61 | |||
| 62 | public function setModelClassName(string $modelClassName): self |
||
| 63 | { |
||
| 64 | $this->modelClassName = $modelClassName; |
||
| 65 | |||
| 66 | return $this; |
||
| 67 | } |
||
| 68 | |||
| 69 | public function getSearchView(): string |
||
| 70 | { |
||
| 71 | return $this->searchView; |
||
| 72 | } |
||
| 73 | |||
| 74 | public function setSearchView(string $searchView): self |
||
| 75 | { |
||
| 76 | $this->searchView = $searchView; |
||
| 77 | |||
| 78 | return $this; |
||
| 79 | } |
||
| 80 | |||
| 81 | public function getColumns(): array |
||
| 82 | { |
||
| 83 | $columnsWithLabels = []; |
||
| 84 | foreach ($this->columns as $type) { |
||
| 85 | $resourceModel = (new Resource(['type' => $type]))->buildResourceModel($this); |
||
| 86 | $columnsWithLabels[$type] = $resourceModel->decorator()->displayTitle(); |
||
| 87 | } |
||
| 88 | |||
| 89 | return $columnsWithLabels; |
||
| 90 | } |
||
| 91 | |||
| 92 | public function setColumns(array $columns): self |
||
| 93 | { |
||
| 94 | $this->columns = $columns; |
||
| 95 | |||
| 96 | return $this; |
||
| 97 | } |
||
| 98 | |||
| 99 | public function getToObjectUrl(): string |
||
| 100 | { |
||
| 101 | return $this->toObjectUrl; |
||
| 102 | } |
||
| 103 | |||
| 104 | public function setToObjectUrl(string $toObjectUrl): self |
||
| 105 | { |
||
| 106 | $this->toObjectUrl = $toObjectUrl; |
||
| 107 | |||
| 108 | return $this; |
||
| 109 | } |
||
| 110 | |||
| 111 | public function getFullTypePrefix(): string |
||
| 112 | { |
||
| 113 | return $this->fullTypePrefix ?? 'overuse'; |
||
| 114 | } |
||
| 115 | |||
| 116 | public function setFullTypePrefix(string $fullTypePrefix): self |
||
| 117 | { |
||
| 118 | $this->fullTypePrefix = $fullTypePrefix; |
||
| 119 | |||
| 120 | return $this; |
||
| 121 | } |
||
| 122 | |||
| 123 | public function getResourceModelClassName(): string |
||
| 124 | { |
||
| 125 | return $this->resourceModelClassName; |
||
| 126 | } |
||
| 127 | |||
| 128 | public function setResourceModelClassName(string $resourceModelClassName): self |
||
| 129 | { |
||
| 130 | $this->resourceModelClassName = $resourceModelClassName; |
||
| 131 | |||
| 132 | return $this; |
||
| 133 | } |
||
| 134 | |||
| 135 | protected function __clone() |
||
| 136 | { |
||
| 137 | } |
||
| 138 | |||
| 139 | public function __wakeup() |
||
| 140 | { |
||
| 141 | throw new RunTimeException('Cannot unserialize singleton'); |
||
| 142 | } |
||
| 143 | |||
| 144 | public static function build(): self |
||
| 145 | { |
||
| 146 | if (!isset(self::$configurator)) { |
||
| 147 | self::$configurator = new self(); |
||
| 148 | } |
||
| 149 | |||
| 150 | return self::$configurator; |
||
| 151 | } |
||
| 152 | |||
| 153 | public function getFilterColumns(): array |
||
| 154 | { |
||
| 155 | $columns = []; |
||
| 156 | foreach ($this->getColumns() as $type => $label) { |
||
| 157 | $columns['overuse,' . $type] = $label; |
||
| 158 | } |
||
| 159 | |||
| 160 | return $columns; |
||
| 161 | } |
||
| 162 | |||
| 163 | public function getTypes(): array |
||
| 164 | { |
||
| 165 | return array_keys($this->getColumns()); |
||
| 166 | } |
||
| 167 | |||
| 168 | public function getModel($params = []) |
||
| 169 | { |
||
| 170 | return $this->createObject($this->getModelClassName(), $params); |
||
| 171 | } |
||
| 172 | |||
| 173 | public function getSearchModel($params = []) |
||
| 174 | { |
||
| 175 | return $this->createObject($this->getSearchModelClassName(), $params); |
||
| 176 | } |
||
| 177 | |||
| 178 | public function getResourceModel($params = []) |
||
| 179 | { |
||
| 180 | return $this->createObject($this->getResourceModelClassName(), $params); |
||
| 181 | } |
||
| 182 | |||
| 183 | private function createObject(string $className, $params = []) |
||
| 184 | { |
||
| 185 | return Yii::createObject(array_merge(['class' => $className], $params)); |
||
| 186 | } |
||
| 187 | |||
| 188 | public function getModelName(): string |
||
| 189 | { |
||
| 190 | return call_user_func([$this->getModel(), 'modelName']); |
||
| 191 | } |
||
| 192 | } |
||
| 193 |