@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | $array['fields'][] = $field->__toArray(); |
43 | 43 | } |
44 | 44 | usort($array['fields'], function($fieldA, $fieldB) { |
45 | - if((bool)$fieldA['required'] !== (bool)$fieldB['required']) { |
|
46 | - if((bool)$fieldA['required']) { |
|
45 | + if ((bool)$fieldA['required'] !== (bool)$fieldB['required']) { |
|
46 | + if ((bool)$fieldA['required']) { |
|
47 | 47 | return -1; |
48 | - } else { |
|
48 | + }else { |
|
49 | 49 | return 1; |
50 | 50 | } |
51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | return ($aOrder < $bOrder) ? -1 : 1; |
58 | 58 | }); |
59 | - foreach($this->actions as $action) { |
|
59 | + foreach ($this->actions as $action) { |
|
60 | 60 | $array['actions'][] = $action->__toArray(); |
61 | 61 | } |
62 | 62 | return $array; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | if (preg_match('/^asc$/i', $direction)) { |
64 | 64 | return self::ASC; |
65 | - } else { |
|
65 | + }else { |
|
66 | 66 | return self::DESC; |
67 | 67 | } |
68 | 68 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function fromArray(array $object = array()) |
83 | 83 | { |
84 | - foreach($object as $field => $order) { |
|
84 | + foreach ($object as $field => $order) { |
|
85 | 85 | $this->addOrder($field, $order); |
86 | 86 | } |
87 | 87 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public function __construct($hydrate = true) |
20 | 20 | { |
21 | 21 | parent::__construct(); |
22 | - if($hydrate) { |
|
22 | + if ($hydrate) { |
|
23 | 23 | $this->fromArray(Request::getInstance()->getData()); |
24 | 24 | } |
25 | 25 | } |
@@ -47,22 +47,22 @@ discard block |
||
47 | 47 | /** @var \ReflectionProperty $property */ |
48 | 48 | foreach ($properties as $property) { |
49 | 49 | $value = $property->getValue($this); |
50 | - if(is_object($value) && method_exists($value, 'toArray')) { |
|
50 | + if (is_object($value) && method_exists($value, 'toArray')) { |
|
51 | 51 | $dto[$property->getName()] = $value->toArray(); |
52 | - } elseif(is_array($value)) { |
|
53 | - foreach($value as &$arrValue) { |
|
54 | - if($arrValue instanceof Dto) { |
|
52 | + } elseif (is_array($value)) { |
|
53 | + foreach ($value as &$arrValue) { |
|
54 | + if ($arrValue instanceof Dto) { |
|
55 | 55 | $arrValue = $arrValue->toArray(); |
56 | 56 | } |
57 | 57 | } |
58 | 58 | $dto[$property->getName()] = $value; |
59 | - } else { |
|
59 | + }else { |
|
60 | 60 | $dto[$property->getName()] = $property->getValue($this); |
61 | 61 | } |
62 | 62 | } |
63 | 63 | } |
64 | - } catch (\Exception $e) { |
|
65 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
64 | + }catch (\Exception $e) { |
|
65 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
66 | 66 | } |
67 | 67 | return $dto; |
68 | 68 | } |
@@ -85,26 +85,26 @@ discard block |
||
85 | 85 | protected function parseDtoField(array $properties, $key, $value = null) { |
86 | 86 | list($type, $isArray) = $this->extractTypes($properties, $key); |
87 | 87 | $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null; |
88 | - if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) { |
|
89 | - if(null !== $value && is_array($value)) { |
|
90 | - if(!array_key_exists($type, $this->__cache)) { |
|
88 | + if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) { |
|
89 | + if (null !== $value && is_array($value)) { |
|
90 | + if (!array_key_exists($type, $this->__cache)) { |
|
91 | 91 | $this->__cache[$type] = new $type(false); |
92 | 92 | } |
93 | - if($isArray) { |
|
93 | + if ($isArray) { |
|
94 | 94 | $this->$key = []; |
95 | - foreach($value as $data) { |
|
96 | - if(null !== $data && is_array($data)) { |
|
95 | + foreach ($value as $data) { |
|
96 | + if (null !== $data && is_array($data)) { |
|
97 | 97 | $dto = clone $this->__cache[$type]; |
98 | 98 | $dto->fromArray($data); |
99 | 99 | array_push($this->$key, $dto); |
100 | 100 | } |
101 | 101 | } |
102 | - } else { |
|
102 | + }else { |
|
103 | 103 | $this->$key = clone $this->__cache[$type]; |
104 | 104 | $this->$key->fromArray($value); |
105 | 105 | } |
106 | 106 | } |
107 | - } else { |
|
107 | + }else { |
|
108 | 108 | $this->castValue($key, $value, $type); |
109 | 109 | } |
110 | 110 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | } |
16 | 16 | |
17 | 17 | public static function parseRawData($type, $params) { |
18 | - switch($type) { |
|
18 | + switch ($type) { |
|
19 | 19 | default: |
20 | 20 | case self::TYPE_HTTP: |
21 | 21 | $parsedParams = http_build_query($params); |
@@ -141,7 +141,7 @@ |
||
141 | 141 | $tmp = []; |
142 | 142 | if (null === $node) { |
143 | 143 | $node = $value; |
144 | - } else { |
|
144 | + }else { |
|
145 | 145 | $tmp = $this->getTmpAttribute($node); |
146 | 146 | } |
147 | 147 | if (null !== $node) { |
@@ -17,7 +17,7 @@ |
||
17 | 17 | public static function updateCacheVar() { |
18 | 18 | $now = new \DateTime(null, new \DateTimeZone(Config::getParam('project.timezone', 'Europe/Madrid'))); |
19 | 19 | $config = Config::getInstance()->dumpConfig(); |
20 | - $config[self::CACHE_VAR_TAG] = 'v' . $now->format('Ymd.His'); |
|
20 | + $config[self::CACHE_VAR_TAG] = 'v'.$now->format('Ymd.His'); |
|
21 | 21 | Config::save($config); |
22 | 22 | return $config[self::CACHE_VAR_TAG]; |
23 | 23 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function generateModule() |
30 | 30 | { |
31 | - Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri()); |
|
31 | + Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri()); |
|
32 | 32 | /* @var $form \PSFS\base\config\ConfigForm */ |
33 | 33 | $form = new ModuleForm(); |
34 | 34 | $form->build(); |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | $this->gen->createStructureModule($module, false, $type, $apiClass); |
61 | 61 | Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, t("Módulo %s generado correctamente"))); |
62 | 62 | // Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true)); |
63 | - } catch (\Exception $e) { |
|
64 | - Logger::log($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]"); |
|
63 | + }catch (\Exception $e) { |
|
64 | + Logger::log($e->getMessage()." [".$e->getFile().":".$e->getLine()."]"); |
|
65 | 65 | Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage())); |
66 | 66 | } |
67 | 67 | } |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | $objects = scandir($dir); |
24 | 24 | foreach ($objects as $object) { |
25 | 25 | if ($object != "." && $object != "..") { |
26 | - if (filetype($dir . "/" . $object) == "dir") { |
|
27 | - self::deleteDir($dir . "/" . $object); |
|
28 | - } else { |
|
29 | - unlink($dir . "/" . $object); |
|
26 | + if (filetype($dir."/".$object) == "dir") { |
|
27 | + self::deleteDir($dir."/".$object); |
|
28 | + }else { |
|
29 | + unlink($dir."/".$object); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | } |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | { |
43 | 43 | $rootDirs = array("css", "js", "media", "font"); |
44 | 44 | foreach ($rootDirs as $dir) { |
45 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
45 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
46 | 46 | try { |
47 | - self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
48 | - } catch (\Exception $e) { |
|
47 | + self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
48 | + }catch (\Exception $e) { |
|
49 | 49 | syslog(LOG_INFO, $e->getMessage()); |
50 | 50 | } |
51 | 51 | } |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | { |
62 | 62 | try { |
63 | 63 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
64 | - throw new \Exception(t('Can\'t create directory ') . $dir); |
|
64 | + throw new \Exception(t('Can\'t create directory ').$dir); |
|
65 | 65 | } |
66 | - } catch (\Exception $e) { |
|
66 | + }catch (\Exception $e) { |
|
67 | 67 | syslog(LOG_WARNING, $e->getMessage()); |
68 | 68 | if (!file_exists(dirname($dir))) { |
69 | - throw new GeneratorException($e->getMessage() . $dir); |
|
69 | + throw new GeneratorException($e->getMessage().$dir); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public static function getTemplatePath() |
79 | 79 | { |
80 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
80 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
81 | 81 | return realpath($path); |
82 | 82 | } |
83 | 83 | |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | * @throws \ReflectionException |
97 | 97 | */ |
98 | 98 | public static function checkCustomNamespaceApi($namespace) { |
99 | - if(!empty($namespace)) { |
|
100 | - if(class_exists($namespace)) { |
|
99 | + if (!empty($namespace)) { |
|
100 | + if (class_exists($namespace)) { |
|
101 | 101 | $reflector = new \ReflectionClass($namespace); |
102 | - if(!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) { |
|
102 | + if (!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) { |
|
103 | 103 | throw new GeneratorException(t('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501); |
104 | - } elseif(!$reflector->isAbstract()) { |
|
104 | + } elseif (!$reflector->isAbstract()) { |
|
105 | 105 | throw new GeneratorException(t('La clase definida debe ser abstracta'), 501); |
106 | 106 | } |
107 | - } else { |
|
107 | + }else { |
|
108 | 108 | throw new GeneratorException(t('La clase definida para extender la API no existe'), 501); |
109 | 109 | } |
110 | 110 | } |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | * @return array |
116 | 116 | */ |
117 | 117 | public static function getDomainPaths($domain) { |
118 | - $domains = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json'), true); |
|
118 | + $domains = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json'), true); |
|
119 | 119 | $paths = []; |
120 | - if(null !== $domains) { |
|
120 | + if (null !== $domains) { |
|
121 | 121 | $keyDomains = array_keys($domains); |
122 | - foreach($keyDomains as $keyDomain) { |
|
122 | + foreach ($keyDomains as $keyDomain) { |
|
123 | 123 | $key = strtoupper(str_replace(['@', '/'], '', $keyDomain)); |
124 | - if(strtoupper($domain) === $key) { |
|
124 | + if (strtoupper($domain) === $key) { |
|
125 | 125 | $paths = $domains[$keyDomain]; |
126 | 126 | break; |
127 | 127 | } |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public static function createRoot($path = WEB_DIR, OutputInterface $output = null) { |
139 | 139 | |
140 | - if(null === $output) { |
|
140 | + if (null === $output) { |
|
141 | 141 | $output = new ConsoleOutput(); |
142 | 142 | } |
143 | 143 | |
144 | 144 | GeneratorHelper::createDir($path); |
145 | 145 | $paths = array("js", "css", "img", "media", "font"); |
146 | 146 | foreach ($paths as $htmlPath) { |
147 | - GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath); |
|
147 | + GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // Generates the root needed files |
@@ -157,18 +157,18 @@ discard block |
||
157 | 157 | ]; |
158 | 158 | $output->writeln('Start creating html files'); |
159 | 159 | foreach ($files as $templates => $filename) { |
160 | - $text = Template::getInstance()->dump("generator/html/" . $templates . '.html.twig'); |
|
161 | - if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) { |
|
162 | - $output->writeln('Can\t create the file ' . $filename); |
|
163 | - } else { |
|
164 | - $output->writeln($filename . ' created successfully'); |
|
160 | + $text = Template::getInstance()->dump("generator/html/".$templates.'.html.twig'); |
|
161 | + if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) { |
|
162 | + $output->writeln('Can\t create the file '.$filename); |
|
163 | + }else { |
|
164 | + $output->writeln($filename.' created successfully'); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | //Export base locale translations |
169 | - if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) { |
|
170 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
171 | - GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
169 | + if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) { |
|
170 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
171 | + GeneratorService::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
175 | 175 | \ No newline at end of file |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | protected $isMultipart = false; |
71 | 71 | |
72 | 72 | private function closeConnection() { |
73 | - if(null !== $this->con) { |
|
74 | - if(is_resource($this->con)) { |
|
73 | + if (null !== $this->con) { |
|
74 | + if (is_resource($this->con)) { |
|
75 | 75 | @curl_close($this->con); |
76 | - } else { |
|
76 | + }else { |
|
77 | 77 | $this->con = null; |
78 | 78 | } |
79 | 79 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function setIsJson($isJson = true) { |
239 | 239 | $this->isJson = $isJson; |
240 | - if($isJson) { |
|
240 | + if ($isJson) { |
|
241 | 241 | $this->setIsMultipart(false); |
242 | 242 | } |
243 | 243 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function setIsMultipart($isMultipart = true) { |
256 | 256 | $this->isMultipart = $isMultipart; |
257 | - if($isMultipart) { |
|
257 | + if ($isMultipart) { |
|
258 | 258 | $this->setIsJson(false); |
259 | 259 | } |
260 | 260 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $this->url = NULL; |
275 | 275 | $this->params = array(); |
276 | 276 | $this->headers = array(); |
277 | - Logger::log('Context service for ' . static::class . ' cleared!'); |
|
277 | + Logger::log('Context service for '.static::class.' cleared!'); |
|
278 | 278 | $this->closeConnection(); |
279 | 279 | } |
280 | 280 | |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | protected function applyOptions() { |
320 | - if(count($this->options)) { |
|
320 | + if (count($this->options)) { |
|
321 | 321 | curl_setopt_array($this->con, $this->options); |
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | 325 | protected function applyHeaders() { |
326 | 326 | $headers = []; |
327 | - foreach($this->headers as $key => $value) { |
|
328 | - $headers[] = $key . ': ' . $value; |
|
327 | + foreach ($this->headers as $key => $value) { |
|
328 | + $headers[] = $key.': '.$value; |
|
329 | 329 | } |
330 | 330 | $headers[self::PSFS_TRACK_HEADER] = Logger::getUid(); |
331 | - if(count($headers)) { |
|
331 | + if (count($headers)) { |
|
332 | 332 | curl_setopt($this->con, CURLOPT_HTTPHEADER, $headers); |
333 | 333 | } |
334 | 334 | } |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | * @return int |
338 | 338 | */ |
339 | 339 | private function parseServiceType() { |
340 | - if($this->getIsJson()) { |
|
340 | + if ($this->getIsJson()) { |
|
341 | 341 | return ServiceHelper::TYPE_JSON; |
342 | 342 | } |
343 | - if($this->getIsMultipart()) { |
|
343 | + if ($this->getIsMultipart()) { |
|
344 | 344 | return ServiceHelper::TYPE_MULTIPART; |
345 | 345 | } |
346 | 346 | return ServiceHelper::TYPE_HTTP; |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | case Request::VERB_GET: |
354 | 354 | default: |
355 | 355 | $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_GET); |
356 | - if(!empty($this->params)) { |
|
356 | + if (!empty($this->params)) { |
|
357 | 357 | $sep = false === strpos($this->getUrl(), '?') ? '?' : ''; |
358 | - $this->url = $this->url . $sep . http_build_query($this->params); |
|
358 | + $this->url = $this->url.$sep.http_build_query($this->params); |
|
359 | 359 | } |
360 | 360 | break; |
361 | 361 | case Request::VERB_POST: |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | $this->applyOptions(); |
388 | 388 | $this->applyHeaders(); |
389 | 389 | $verbose = null; |
390 | - if('debug' === Config::getParam('log.level')) { |
|
390 | + if ('debug' === Config::getParam('log.level')) { |
|
391 | 391 | curl_setopt($this->con, CURLOPT_VERBOSE, true); |
392 | 392 | $verbose = fopen('php://temp', 'wb+'); |
393 | 393 | curl_setopt($this->con, CURLOPT_STDERR, $verbose); |
394 | 394 | } |
395 | 395 | $result = curl_exec($this->con); |
396 | 396 | $this->setResult($this->isJson ? json_decode($result, true) : $result); |
397 | - if('debug' === Config::getParam('log.level')) { |
|
397 | + if ('debug' === Config::getParam('log.level')) { |
|
398 | 398 | rewind($verbose); |
399 | 399 | $verboseLog = stream_get_contents($verbose); |
400 | 400 | Logger::log($verboseLog, LOG_DEBUG, [ |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | ]); |
405 | 405 | $this->info['verbose'] = $verboseLog; |
406 | 406 | } |
407 | - Logger::log($this->url . ' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]); |
|
407 | + Logger::log($this->url.' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]); |
|
408 | 408 | $this->info = array_merge($this->info, curl_getinfo($this->con)); |
409 | 409 | } |
410 | 410 |