@@ -39,8 +39,8 @@ |
||
39 | 39 | "domain" => $this->getDomain(), |
40 | 40 | "listLabel" => Api::API_LIST_NAME_FIELD, |
41 | 41 | 'modelId' => Api::API_MODEL_KEY_FIELD, |
42 | - 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)), |
|
43 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)), |
|
42 | + 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)), |
|
43 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)), |
|
44 | 44 | ), [], ''); |
45 | 45 | } |
46 | 46 |
@@ -6,7 +6,6 @@ |
||
6 | 6 | use Propel\Runtime\Propel; |
7 | 7 | use PSFS\base\config\Config; |
8 | 8 | use PSFS\base\Logger; |
9 | -use PSFS\base\types\traits\DebugTrait; |
|
10 | 9 | |
11 | 10 | /** |
12 | 11 | * Trait ConnectionTrait |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | protected function createConnection(TableMap $tableMap) |
27 | 27 | { |
28 | 28 | $this->con = Propel::getConnection($tableMap::DATABASE_NAME); |
29 | - if(method_exists($this->con, 'useDebug')) { |
|
29 | + if (method_exists($this->con, 'useDebug')) { |
|
30 | 30 | Logger::log('Enabling debug queries mode', LOG_INFO); |
31 | 31 | $this->con->useDebug(Config::getParam('debug')); |
32 | 32 | } |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | */ |
40 | 40 | protected function closeTransaction($status) |
41 | 41 | { |
42 | - if(null !== $this->con) { |
|
42 | + if (null !== $this->con) { |
|
43 | 43 | $this->traceDebugQuery(); |
44 | 44 | if (null !== $this->con && $this->con->inTransaction()) { |
45 | 45 | if ($status === 200) { |
46 | 46 | $this->con->commit(); |
47 | - } else { |
|
47 | + }else { |
|
48 | 48 | $this->con->rollBack(); |
49 | 49 | } |
50 | 50 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | $this->success = $result; |
43 | 43 | $this->total = $total ?: count($data); |
44 | 44 | $this->pages = $pages; |
45 | - if(null !== $message) { |
|
45 | + if (null !== $message) { |
|
46 | 46 | $this->message = $message; |
47 | 47 | } |
48 | 48 | } |
@@ -3,15 +3,12 @@ |
||
3 | 3 | |
4 | 4 | use Propel\Runtime\ActiveQuery\ModelCriteria; |
5 | 5 | use Propel\Runtime\Map\TableMap; |
6 | -use PSFS\base\config\Config; |
|
7 | 6 | use PSFS\base\dto\JsonResponse; |
8 | 7 | use PSFS\base\dto\Order; |
9 | 8 | use PSFS\base\Logger; |
10 | 9 | use PSFS\base\Request; |
11 | -use PSFS\base\Security; |
|
12 | 10 | use PSFS\base\Singleton; |
13 | 11 | use PSFS\base\types\helpers\ApiHelper; |
14 | -use PSFS\base\types\helpers\Inspector; |
|
15 | 12 | use PSFS\base\types\traits\Api\ManagerTrait; |
16 | 13 | |
17 | 14 | /** |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | public function init() |
73 | 73 | { |
74 | 74 | parent::init(); |
75 | - Logger::log(get_called_class() . ' init', LOG_DEBUG); |
|
75 | + Logger::log(get_called_class().' init', LOG_DEBUG); |
|
76 | 76 | $this->domain = $this->getDomain(); |
77 | 77 | $this->hydrateRequestData(); |
78 | 78 | $this->hydrateOrders(); |
79 | - if($this instanceof CustomApi === false) { |
|
79 | + if ($this instanceof CustomApi === false) { |
|
80 | 80 | $this->createConnection($this->getTableMap()); |
81 | 81 | } |
82 | 82 | $this->setLoaded(true); |
83 | - Logger::log(get_called_class() . ' loaded', LOG_DEBUG); |
|
83 | + Logger::log(get_called_class().' loaded', LOG_DEBUG); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | protected function hydrateOrders() |
90 | 90 | { |
91 | 91 | if (count($this->query)) { |
92 | - Logger::log(get_called_class() . ' gathering query string', LOG_DEBUG); |
|
92 | + Logger::log(get_called_class().' gathering query string', LOG_DEBUG); |
|
93 | 93 | foreach ($this->query as $key => $value) { |
94 | 94 | if ($key === self::API_ORDER_FIELD) { |
95 | 95 | foreach ($value as $field => $direction) { |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function extractPagination() |
108 | 108 | { |
109 | - Logger::log(get_called_class() . ' extract pagination start', LOG_DEBUG); |
|
109 | + Logger::log(get_called_class().' extract pagination start', LOG_DEBUG); |
|
110 | 110 | $page = (array_key_exists(self::API_PAGE_FIELD, $this->query)) ? $this->query[self::API_PAGE_FIELD] : 1; |
111 | 111 | $limit = (array_key_exists(self::API_LIMIT_FIELD, $this->query)) ? $this->query[self::API_LIMIT_FIELD] : 100; |
112 | - Logger::log(get_called_class() . ' extract pagination end', LOG_DEBUG); |
|
112 | + Logger::log(get_called_class().' extract pagination end', LOG_DEBUG); |
|
113 | 113 | return array($page, $limit); |
114 | 114 | } |
115 | 115 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @param ModelCriteria $query |
120 | 120 | */ |
121 | - private function addOrders(ModelCriteria &$query) |
|
121 | + private function addOrders(ModelCriteria & $query) |
|
122 | 122 | { |
123 | - Logger::log(get_called_class() . ' extract orders start ', LOG_DEBUG); |
|
123 | + Logger::log(get_called_class().' extract orders start ', LOG_DEBUG); |
|
124 | 124 | $orderAdded = FALSE; |
125 | 125 | $tableMap = $this->getTableMap(); |
126 | 126 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -128,17 +128,17 @@ discard block |
||
128 | 128 | $orderAdded = TRUE; |
129 | 129 | if ($direction === Order::ASC) { |
130 | 130 | $query->addAscendingOrderByColumn($column->getPhpName()); |
131 | - } else { |
|
131 | + }else { |
|
132 | 132 | $query->addDescendingOrderByColumn($column->getPhpName()); |
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | if (!$orderAdded) { |
137 | - foreach($this->getPkDbName() as $pk => $phpName) { |
|
137 | + foreach ($this->getPkDbName() as $pk => $phpName) { |
|
138 | 138 | $query->addAscendingOrderByColumn($pk); |
139 | 139 | } |
140 | 140 | } |
141 | - Logger::log(get_called_class() . ' extract orders end', LOG_DEBUG); |
|
141 | + Logger::log(get_called_class().' extract orders end', LOG_DEBUG); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @param ModelCriteria $query |
148 | 148 | */ |
149 | - protected function addFilters(ModelCriteria &$query) |
|
149 | + protected function addFilters(ModelCriteria & $query) |
|
150 | 150 | { |
151 | 151 | if (count($this->query) > 0) { |
152 | 152 | $tableMap = $this->getTableMap(); |
153 | 153 | foreach ($this->query as $field => $value) { |
154 | 154 | if (self::API_COMBO_FIELD === $field) { |
155 | 155 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
156 | - } elseif(!preg_match('/^__/', $field)) { |
|
156 | + } elseif (!preg_match('/^__/', $field)) { |
|
157 | 157 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
158 | 158 | } |
159 | 159 | } |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | list($page, $limit) = $this->extractPagination(); |
175 | 175 | if ($limit == -1) { |
176 | 176 | $this->list = $query->find($this->con); |
177 | - } else { |
|
177 | + }else { |
|
178 | 178 | $this->list = $query->paginate($page, $limit, $this->con); |
179 | 179 | } |
180 | - } catch (\Exception $e) { |
|
180 | + }catch (\Exception $e) { |
|
181 | 181 | Logger::log($e->getMessage(), LOG_ERR); |
182 | 182 | } |
183 | 183 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $code = 200; |
197 | 197 | list($return, $total, $pages) = $this->getList(); |
198 | 198 | $message = null; |
199 | - if(!$total) { |
|
199 | + if (!$total) { |
|
200 | 200 | $message = _('No se han encontrado elementos para la búsqueda'); |
201 | 201 | } |
202 | 202 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $pages = 1; |
223 | 223 | $message = null; |
224 | 224 | list($code, $return) = $this->getSingleResult($pk); |
225 | - if($code !== 200) { |
|
225 | + if ($code !== 200) { |
|
226 | 226 | $message = _('No se ha encontrado el elemento solicitado'); |
227 | 227 | } |
228 | 228 | |
@@ -251,11 +251,11 @@ discard block |
||
251 | 251 | $status = 200; |
252 | 252 | $saved = TRUE; |
253 | 253 | $model = $this->model->toArray(); |
254 | - } else { |
|
254 | + }else { |
|
255 | 255 | $message = _('No se ha podido guardar el modelo seleccionado'); |
256 | 256 | } |
257 | - } catch (\Exception $e) { |
|
258 | - $message = _('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage(); |
|
257 | + }catch (\Exception $e) { |
|
258 | + $message = _('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage(); |
|
259 | 259 | Logger::log($e->getMessage(), LOG_ERR); |
260 | 260 | } |
261 | 261 | |
@@ -289,14 +289,14 @@ discard block |
||
289 | 289 | $updated = TRUE; |
290 | 290 | $status = 200; |
291 | 291 | $model = $this->model->toArray(); |
292 | - } else { |
|
292 | + }else { |
|
293 | 293 | $message = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
294 | 294 | } |
295 | - } catch (\Exception $e) { |
|
295 | + }catch (\Exception $e) { |
|
296 | 296 | $message = $e->getMessage(); |
297 | 297 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
298 | 298 | } |
299 | - } else { |
|
299 | + }else { |
|
300 | 300 | $message = _('No se ha encontrado el modelo al que se hace referencia para actualizar'); |
301 | 301 | } |
302 | 302 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $this->model->delete($this->con); |
327 | 327 | $deleted = TRUE; |
328 | 328 | } |
329 | - } catch (\Exception $e) { |
|
329 | + }catch (\Exception $e) { |
|
330 | 330 | $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados'); |
331 | 331 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
332 | 332 | } |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | $total = $this->list->getNbResults(); |
361 | 361 | $pages = $this->list->getLastPage(); |
362 | 362 | } |
363 | - } catch (\Exception $e) { |
|
364 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
363 | + }catch (\Exception $e) { |
|
364 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | return array($return, $total, $pages); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | $return = array(); |
380 | 380 | if (NULL === $model || !method_exists($model, 'toArray')) { |
381 | 381 | $code = 404; |
382 | - } else { |
|
382 | + }else { |
|
383 | 383 | $return = $model->toArray(); |
384 | 384 | } |
385 | 385 |
@@ -2,15 +2,11 @@ |
||
2 | 2 | namespace PSFS\base\types; |
3 | 3 | |
4 | 4 | use PSFS\base\config\Config; |
5 | -use PSFS\base\exception\RouterException; |
|
6 | -use PSFS\base\Request; |
|
7 | -use PSFS\base\Router; |
|
8 | 5 | use PSFS\base\Singleton; |
9 | 6 | use PSFS\base\types\helpers\GeneratorHelper; |
10 | 7 | use PSFS\base\types\helpers\Inspector; |
11 | 8 | use PSFS\base\types\interfaces\ControllerInterface; |
12 | 9 | use PSFS\base\types\traits\JsonTrait; |
13 | -use PSFS\base\types\traits\OutputTrait; |
|
14 | 10 | use PSFS\base\types\traits\RouteTrait; |
15 | 11 | |
16 | 12 | /** |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | public function render($template, array $vars = array(), $cookies = array(), $domain = null) |
42 | 42 | { |
43 | 43 | $vars['__menu__'] = $this->getMenu(); |
44 | - if(Config::getParam('profiling.enable')) { |
|
44 | + if (Config::getParam('profiling.enable')) { |
|
45 | 45 | $vars['__profiling__'] = Inspector::getStats(); |
46 | 46 | } |
47 | 47 | $domain = (null === $domain) ? $this->getDomain() : $domain; |
48 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
48 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | $vars['__menu__'] = $this->getMenu(); |
78 | 78 | $domain = $domain ?: $this->getDomain(); |
79 | - return $this->tpl->dump($domain . $template, $vars); |
|
79 | + return $this->tpl->dump($domain.$template, $vars); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -14,6 +14,9 @@ |
||
14 | 14 | ]; |
15 | 15 | } |
16 | 16 | |
17 | + /** |
|
18 | + * @param string $name |
|
19 | + */ |
|
17 | 20 | public static function stats($name = null) { |
18 | 21 | self::$profiling[] = self::collect($name); |
19 | 22 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | protected static function calculateStats(array $stats, $ts, $mem = 0, $files = 0) { |
29 | 29 | return [ |
30 | 30 | 'ts' => round($stats['ts'] - $ts, 4), |
31 | - 'mem' => round(($stats['mem'] - $mem) / 1024 / 1024, 4), |
|
31 | + 'mem' => round(($stats['mem'] - $mem)/1024/1024, 4), |
|
32 | 32 | 'files' => $stats['files'] - $files, |
33 | 33 | 'name' => $stats['name'], |
34 | 34 | ]; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $ts = defined('PSFS_START_TS') ? PSFS_START_TS : 0; |
43 | 43 | $mem = defined('PSFS_START_MEM') ? PSFS_START_MEM : 0; |
44 | 44 | $files = 0; |
45 | - foreach(self::$profiling as $key => &$value) { |
|
45 | + foreach (self::$profiling as $key => &$value) { |
|
46 | 46 | $value = self::calculateStats($value, $ts, $mem, $files); |
47 | 47 | } |
48 | 48 | self::$profiling[] = self::calculateStats(self::collect('Profiling collect ends'), $ts, $mem, $files); |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * @param mixed $response |
19 | 19 | * @param int $statusCode |
20 | 20 | * |
21 | - * @return mixed JSON |
|
21 | + * @return string|null JSON |
|
22 | 22 | */ |
23 | 23 | public function json($response, $statusCode = 200) |
24 | 24 | { |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function json($response, $statusCode = 200) |
25 | 25 | { |
26 | - if(Config::getParam('profiling.enable')) { |
|
27 | - if(is_array($response)) { |
|
26 | + if (Config::getParam('profiling.enable')) { |
|
27 | + if (is_array($response)) { |
|
28 | 28 | $response['profiling'] = Inspector::getStats(); |
29 | - } elseif($response instanceof JsonResponse) { |
|
29 | + } elseif ($response instanceof JsonResponse) { |
|
30 | 30 | $response = ProfilingJsonResponse::createFromPrevious($response, Inspector::getStats()); |
31 | 31 | } |
32 | 32 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | $this->decodeJsonReponse($response); |
35 | 35 | |
36 | 36 | $data = json_encode($response, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK | JSON_BIGINT_AS_STRING); |
37 | - if(Config::getParam('angular.protection', false)) { |
|
38 | - $data = ")]}',\n" . $data; |
|
37 | + if (Config::getParam('angular.protection', false)) { |
|
38 | + $data = ")]}',\n".$data; |
|
39 | 39 | } |
40 | 40 | $this->setStatus($statusCode); |
41 | 41 | ResponseHelper::setDebugHeaders([]); |
@@ -3,17 +3,17 @@ |
||
3 | 3 | |
4 | 4 | if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__); |
5 | 5 | if (preg_match('/vendor/', SOURCE_DIR)) { |
6 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
7 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
8 | -} else { |
|
9 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
10 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
6 | + if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'); |
|
7 | + if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src'); |
|
8 | +}else { |
|
9 | + if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'); |
|
10 | + if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules'); |
|
11 | 11 | } |
12 | -if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
13 | -if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
14 | -if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
15 | -if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
16 | -if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
12 | +if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor'); |
|
13 | +if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
14 | +if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache'); |
|
15 | +if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config'); |
|
16 | +if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html'); |
|
17 | 17 | |
18 | 18 | |
19 | 19 | /** |
@@ -4,19 +4,39 @@ |
||
4 | 4 | defined('PSFS_START_MEM') or define('PSFS_START_MEM', memory_get_usage()); |
5 | 5 | defined('PSFS_START_TS') or define('PSFS_START_TS', microtime(true)); |
6 | 6 | |
7 | -if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__); |
|
7 | +if (!defined('SOURCE_DIR')) { |
|
8 | + define('SOURCE_DIR', __DIR__); |
|
9 | +} |
|
8 | 10 | if (preg_match('/vendor/', SOURCE_DIR)) { |
9 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
10 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
11 | -} else { |
|
12 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
13 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
11 | + if (!defined('BASE_DIR')) { |
|
12 | + define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
13 | + } |
|
14 | + if (!defined('CORE_DIR')) { |
|
15 | + define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
16 | + } |
|
17 | + } else { |
|
18 | + if (!defined('BASE_DIR')) { |
|
19 | + define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
20 | + } |
|
21 | + if (!defined('CORE_DIR')) { |
|
22 | + define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
23 | + } |
|
24 | + } |
|
25 | +if (!defined('VENDOR_DIR')) { |
|
26 | + define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
27 | +} |
|
28 | +if (!defined('LOG_DIR')) { |
|
29 | + define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
30 | +} |
|
31 | +if (!defined('CACHE_DIR')) { |
|
32 | + define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
33 | +} |
|
34 | +if (!defined('CONFIG_DIR')) { |
|
35 | + define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
36 | +} |
|
37 | +if (!defined('WEB_DIR')) { |
|
38 | + define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
14 | 39 | } |
15 | -if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
16 | -if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
17 | -if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
18 | -if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
19 | -if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
20 | 40 | |
21 | 41 | |
22 | 42 | /** |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class FileHelper { |
10 | 10 | /** |
11 | - * @param mixed $data |
|
11 | + * @param string $data |
|
12 | 12 | * @param string $path |
13 | 13 | * @return int |
14 | 14 | */ |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @param string $path |
21 | - * @return mixed|bool |
|
21 | + * @return string|false |
|
22 | 22 | */ |
23 | 23 | public static function readFile($path) { |
24 | 24 | $data = false; |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | - * @param $path |
|
55 | - * @return bool |
|
54 | + * @param string $path |
|
55 | + * @return boolean|null |
|
56 | 56 | */ |
57 | 57 | public static function deleteDir($path) { |
58 | 58 | (new Filesystem())->remove($path); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public static function readFile($path) { |
24 | 24 | $data = false; |
25 | - if(file_exists($path)) { |
|
25 | + if (file_exists($path)) { |
|
26 | 26 | $data = file_get_contents($path); |
27 | 27 | } |
28 | 28 | return $data; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @return string |
36 | 36 | */ |
37 | 37 | public static function generateHashFilename($verb, $slug, array $query = []) { |
38 | - return sha1(strtolower($verb) . " " . $slug . " " . strtolower(http_build_query($query))); |
|
38 | + return sha1(strtolower($verb)." ".$slug." ".strtolower(http_build_query($query))); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | public static function generateCachePath(array $action, array $query = []) { |
47 | 47 | $class = GeneratorHelper::extractClassFromNamespace($action['class']); |
48 | 48 | $filename = self::generateHashFilename($action["http"], $action["slug"], $query); |
49 | - $subPath = substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2); |
|
50 | - return $action['module'] . DIRECTORY_SEPARATOR . $class . DIRECTORY_SEPARATOR . $action['method'] . DIRECTORY_SEPARATOR . $subPath . DIRECTORY_SEPARATOR; |
|
49 | + $subPath = substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2); |
|
50 | + return $action['module'].DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$action['method'].DIRECTORY_SEPARATOR.$subPath.DIRECTORY_SEPARATOR; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |