@@ -81,20 +81,20 @@ discard block |
||
| 81 | 81 | public function init() |
| 82 | 82 | { |
| 83 | 83 | parent::init(); |
| 84 | - Logger::log(static::class . ' init', LOG_DEBUG); |
|
| 84 | + Logger::log(static::class.' init', LOG_DEBUG); |
|
| 85 | 85 | $this->domain = $this->getDomain(); |
| 86 | 86 | $this->hydrateRequestData(); |
| 87 | 87 | $this->hydrateOrders(); |
| 88 | - if($this instanceof CustomApi === false) { |
|
| 88 | + if ($this instanceof CustomApi === false) { |
|
| 89 | 89 | $this->createConnection($this->getTableMap()); |
| 90 | 90 | } |
| 91 | 91 | $this->checkFieldType(); |
| 92 | 92 | $this->setLoaded(true); |
| 93 | - Logger::log(static::class . ' loaded', LOG_DEBUG); |
|
| 93 | + Logger::log(static::class.' loaded', LOG_DEBUG); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | private function checkActions($method) { |
| 97 | - switch($method) { |
|
| 97 | + switch ($method) { |
|
| 98 | 98 | default: |
| 99 | 99 | case 'modelList': $this->action = self::API_ACTION_LIST; break; |
| 100 | 100 | case 'get': $this->action = self::API_ACTION_GET; break; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | protected function hydrateOrders() |
| 112 | 112 | { |
| 113 | 113 | if (count($this->query)) { |
| 114 | - Logger::log(static::class . ' gathering query string', LOG_DEBUG); |
|
| 114 | + Logger::log(static::class.' gathering query string', LOG_DEBUG); |
|
| 115 | 115 | foreach ($this->query as $key => $value) { |
| 116 | 116 | if ($key === self::API_ORDER_FIELD && is_array($value)) { |
| 117 | 117 | foreach ($value as $field => $direction) { |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | protected function extractPagination() |
| 130 | 130 | { |
| 131 | - Logger::log(static::class . ' extract pagination start', LOG_DEBUG); |
|
| 131 | + Logger::log(static::class.' extract pagination start', LOG_DEBUG); |
|
| 132 | 132 | $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1; |
| 133 | 133 | $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100; |
| 134 | - Logger::log(static::class . ' extract pagination end', LOG_DEBUG); |
|
| 134 | + Logger::log(static::class.' extract pagination end', LOG_DEBUG); |
|
| 135 | 135 | return array($page, (int)$limit); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | private function addOrders(ModelCriteria &$query) |
| 144 | 144 | { |
| 145 | - Logger::log(static::class . ' extract orders start ', LOG_DEBUG); |
|
| 145 | + Logger::log(static::class.' extract orders start ', LOG_DEBUG); |
|
| 146 | 146 | $orderAdded = FALSE; |
| 147 | 147 | $tableMap = $this->getTableMap(); |
| 148 | 148 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -150,18 +150,18 @@ discard block |
||
| 150 | 150 | $orderAdded = TRUE; |
| 151 | 151 | if ($direction === Order::ASC) { |
| 152 | 152 | $query->addAscendingOrderByColumn($column->getPhpName()); |
| 153 | - } else { |
|
| 153 | + }else { |
|
| 154 | 154 | $query->addDescendingOrderByColumn($column->getPhpName()); |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | if (!$orderAdded) { |
| 159 | 159 | $pks = $this->getPkDbName(); |
| 160 | - foreach(array_keys($pks) as $key) { |
|
| 160 | + foreach (array_keys($pks) as $key) { |
|
| 161 | 161 | $query->addAscendingOrderByColumn($key); |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | - Logger::log(static::class . ' extract orders end', LOG_DEBUG); |
|
| 164 | + Logger::log(static::class.' extract orders end', LOG_DEBUG); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | foreach ($this->query as $field => $value) { |
| 177 | 177 | if (self::API_COMBO_FIELD === $field) { |
| 178 | 178 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
| 179 | - } elseif(!preg_match('/^__/', $field)) { |
|
| 179 | + } elseif (!preg_match('/^__/', $field)) { |
|
| 180 | 180 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | list($page, $limit) = $this->extractPagination(); |
| 198 | 198 | if ($limit === -1) { |
| 199 | 199 | $this->list = $query->find($this->con); |
| 200 | - } else { |
|
| 200 | + }else { |
|
| 201 | 201 | $this->list = $query->paginate($page, $limit, $this->con); |
| 202 | 202 | } |
| 203 | - } catch (\Exception $e) { |
|
| 203 | + }catch (\Exception $e) { |
|
| 204 | 204 | Logger::log($e->getMessage(), LOG_ERR); |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | $code = 200; |
| 220 | 220 | list($return, $total, $pages) = $this->getList(); |
| 221 | 221 | $message = null; |
| 222 | - if(!$total) { |
|
| 222 | + if (!$total) { |
|
| 223 | 223 | $message = t('No se han encontrado elementos para la búsqueda'); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $pages = 1; |
| 246 | 246 | $message = null; |
| 247 | 247 | list($code, $return) = $this->getSingleResult($pk); |
| 248 | - if($code !== 200) { |
|
| 248 | + if ($code !== 200) { |
|
| 249 | 249 | $message = t('No se ha encontrado el elemento solicitado'); |
| 250 | 250 | } |
| 251 | 251 | |
@@ -274,13 +274,13 @@ discard block |
||
| 274 | 274 | $status = 200; |
| 275 | 275 | $saved = TRUE; |
| 276 | 276 | $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
| 277 | - } else { |
|
| 277 | + }else { |
|
| 278 | 278 | $message = t('No se ha podido guardar el modelo seleccionado'); |
| 279 | 279 | } |
| 280 | - } catch (\Exception $e) { |
|
| 281 | - $message = t('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage(); |
|
| 280 | + }catch (\Exception $e) { |
|
| 281 | + $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage(); |
|
| 282 | 282 | $context = []; |
| 283 | - if(null !== $e->getPrevious()) { |
|
| 283 | + if (null !== $e->getPrevious()) { |
|
| 284 | 284 | $context[] = $e->getPrevious()->getMessage(); |
| 285 | 285 | } |
| 286 | 286 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
@@ -316,18 +316,18 @@ discard block |
||
| 316 | 316 | $updated = TRUE; |
| 317 | 317 | $status = 200; |
| 318 | 318 | $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
| 319 | - } else { |
|
| 319 | + }else { |
|
| 320 | 320 | $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
| 321 | 321 | } |
| 322 | - } catch (\Exception $e) { |
|
| 322 | + }catch (\Exception $e) { |
|
| 323 | 323 | $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
| 324 | 324 | $context = []; |
| 325 | - if(null !== $e->getPrevious()) { |
|
| 325 | + if (null !== $e->getPrevious()) { |
|
| 326 | 326 | $context[] = $e->getPrevious()->getMessage(); |
| 327 | 327 | } |
| 328 | 328 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
| 329 | 329 | } |
| 330 | - } else { |
|
| 330 | + }else { |
|
| 331 | 331 | $message = t('No se ha encontrado el modelo al que se hace referencia para actualizar'); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -355,15 +355,15 @@ discard block |
||
| 355 | 355 | $this->con->beginTransaction(); |
| 356 | 356 | $this->hydrateModel($pk); |
| 357 | 357 | if (NULL !== $this->model) { |
| 358 | - if(method_exists('clearAllReferences', $this->model)) { |
|
| 358 | + if (method_exists('clearAllReferences', $this->model)) { |
|
| 359 | 359 | $this->model->clearAllReferences(true); |
| 360 | 360 | } |
| 361 | 361 | $this->model->delete($this->con); |
| 362 | 362 | $deleted = TRUE; |
| 363 | 363 | } |
| 364 | - } catch (\Exception $e) { |
|
| 364 | + }catch (\Exception $e) { |
|
| 365 | 365 | $context = []; |
| 366 | - if(null !== $e->getPrevious()) { |
|
| 366 | + if (null !== $e->getPrevious()) { |
|
| 367 | 367 | $context[] = $e->getPrevious()->getMessage(); |
| 368 | 368 | } |
| 369 | 369 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | $this->saveBulk(); |
| 393 | 393 | $saved = true; |
| 394 | 394 | $status = 200; |
| 395 | - } catch(\Exception $e) { |
|
| 395 | + }catch (\Exception $e) { |
|
| 396 | 396 | Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData()); |
| 397 | 397 | $message = t('Bulk insert rolled back'); |
| 398 | 398 | } |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | /** @var CustomerTableMap $tableMap */ |
| 416 | 416 | $modelPk = ApiHelper::extractPrimaryKeyColumnName($this->getTableMap()); |
| 417 | - foreach($this->list->getData() as $data) { |
|
| 417 | + foreach ($this->list->getData() as $data) { |
|
| 418 | 418 | $return[] = ApiHelper::mapArrayObject($this->getModelNamespace(), $modelPk, $this->query, $data); |
| 419 | 419 | } |
| 420 | 420 | return $return; |
@@ -431,23 +431,23 @@ discard block |
||
| 431 | 431 | try { |
| 432 | 432 | $this->paginate(); |
| 433 | 433 | if (null !== $this->list) { |
| 434 | - if(array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
| 434 | + if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
| 435 | 435 | $return = $this->extractDataWithFormat(); |
| 436 | - } else { |
|
| 436 | + }else { |
|
| 437 | 437 | $return = $this->list->toArray(null, false, $this->fieldType ?: TableMap::TYPE_PHPNAME, false); |
| 438 | 438 | } |
| 439 | 439 | $total = 0; |
| 440 | 440 | $pages = 0; |
| 441 | - if($this->list instanceof PropelModelPager) { |
|
| 441 | + if ($this->list instanceof PropelModelPager) { |
|
| 442 | 442 | $total = $this->list->getNbResults(); |
| 443 | 443 | $pages = $this->list->getLastPage(); |
| 444 | - } elseif($this->list instanceof ArrayCollection) { |
|
| 444 | + } elseif ($this->list instanceof ArrayCollection) { |
|
| 445 | 445 | $total = count($return); |
| 446 | 446 | $pages = 1; |
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | - } catch (\Exception $e) { |
|
| 450 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 449 | + }catch (\Exception $e) { |
|
| 450 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | return array($return, $total, $pages); |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | $return = array(); |
| 466 | 466 | if (NULL === $model || !method_exists($model, 'toArray')) { |
| 467 | 467 | $code = 404; |
| 468 | - } else { |
|
| 468 | + }else { |
|
| 469 | 469 | $return = $model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
| 470 | 470 | } |
| 471 | 471 | |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | $objects = scandir($dir); |
| 20 | 20 | foreach ($objects as $object) { |
| 21 | 21 | if ($object != "." && $object != "..") { |
| 22 | - if (filetype($dir . "/" . $object) == "dir") { |
|
| 23 | - self::deleteDir($dir . "/" . $object); |
|
| 24 | - } else { |
|
| 25 | - unlink($dir . "/" . $object); |
|
| 22 | + if (filetype($dir."/".$object) == "dir") { |
|
| 23 | + self::deleteDir($dir."/".$object); |
|
| 24 | + }else { |
|
| 25 | + unlink($dir."/".$object); |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $rootDirs = array("css", "js", "media", "font"); |
| 40 | 40 | foreach ($rootDirs as $dir) { |
| 41 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
| 41 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
| 42 | 42 | try { |
| 43 | - self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
| 44 | - } catch (\Exception $e) { |
|
| 43 | + self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
| 44 | + }catch (\Exception $e) { |
|
| 45 | 45 | Logger::log($e->getMessage()); |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | try { |
| 59 | 59 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
| 60 | - throw new \Exception(t('Can\'t create directory ') . $dir); |
|
| 60 | + throw new \Exception(t('Can\'t create directory ').$dir); |
|
| 61 | 61 | } |
| 62 | - } catch (\Exception $e) { |
|
| 62 | + }catch (\Exception $e) { |
|
| 63 | 63 | Logger::log($e->getMessage(), LOG_WARNING); |
| 64 | 64 | if (!file_exists(dirname($dir))) { |
| 65 | - throw new GeneratorException($e->getMessage() . $dir); |
|
| 65 | + throw new GeneratorException($e->getMessage().$dir); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public static function getTemplatePath() |
| 75 | 75 | { |
| 76 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
| 76 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
| 77 | 77 | return realpath($path); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -91,15 +91,15 @@ discard block |
||
| 91 | 91 | * @throws GeneratorException |
| 92 | 92 | */ |
| 93 | 93 | public static function checkCustomNamespaceApi($namespace) { |
| 94 | - if(!empty($namespace)) { |
|
| 95 | - if(class_exists($namespace)) { |
|
| 94 | + if (!empty($namespace)) { |
|
| 95 | + if (class_exists($namespace)) { |
|
| 96 | 96 | $reflector = new \ReflectionClass($namespace); |
| 97 | - if(!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) { |
|
| 97 | + if (!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) { |
|
| 98 | 98 | throw new GeneratorException(t('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501); |
| 99 | - } elseif(!$reflector->isAbstract()) { |
|
| 99 | + } elseif (!$reflector->isAbstract()) { |
|
| 100 | 100 | throw new GeneratorException(t('La clase definida debe ser abstracta'), 501); |
| 101 | 101 | } |
| 102 | - } else { |
|
| 102 | + }else { |
|
| 103 | 103 | throw new GeneratorException(t('La clase definida para extender la API no existe'), 501); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | $isRequired = self::checkIsRequired($property->getDocComment()); |
| 27 | 27 | $label = self::getLabel($property->getDocComment()); |
| 28 | 28 | $isArray = (bool)preg_match('/\[\]$/', $instanceType); |
| 29 | - if($isArray) { |
|
| 29 | + if ($isArray) { |
|
| 30 | 30 | $instanceType = str_replace('[]', '', $instanceType); |
| 31 | 31 | } |
| 32 | - if($instanceType === '\\DateTime' || !Router::exists($instanceType)) { |
|
| 32 | + if ($instanceType === '\\DateTime' || !Router::exists($instanceType)) { |
|
| 33 | 33 | list($type, $format) = DocumentorHelper::translateSwaggerFormats($instanceType); |
| 34 | 34 | $variables[$property->getName()] = [ |
| 35 | 35 | 'type' => $type, |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | 'required' => $isRequired, |
| 38 | 38 | 'description' => $label, |
| 39 | 39 | ]; |
| 40 | - } else { |
|
| 40 | + }else { |
|
| 41 | 41 | $instance = new \ReflectionClass($instanceType); |
| 42 | 42 | $variables[$property->getName()] = [ |
| 43 | 43 | 'is_array' => $isArray, |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | // Extract description |
| 124 | 124 | $label = null; |
| 125 | 125 | preg_match('/@label\ (.*)\n/i', $doc, $matches); |
| 126 | - if(count($matches)) { |
|
| 126 | + if (count($matches)) { |
|
| 127 | 127 | $label = t($matches[1]); |
| 128 | 128 | } |
| 129 | 129 | return $label; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | public static function getDefaultValue($doc) { |
| 137 | 137 | $default = null; |
| 138 | 138 | preg_match('/@default\ (.*)\n/i', $doc, $matches); |
| 139 | - if(count($matches)) { |
|
| 139 | + if (count($matches)) { |
|
| 140 | 140 | $default = $matches[1]; |
| 141 | 141 | } |
| 142 | 142 | return $default; |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public static function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
| 153 | 153 | { |
| 154 | - Logger::log('Create inyectable instance for ' . $classNameSpace); |
|
| 154 | + Logger::log('Create inyectable instance for '.$classNameSpace); |
|
| 155 | 155 | $reflector = new \ReflectionClass($calledClass); |
| 156 | 156 | $property = $reflector->getProperty($variable); |
| 157 | 157 | $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace; |
| 158 | 158 | if (true === $singleton && method_exists($varInstanceType, 'getInstance')) { |
| 159 | 159 | $instance = $varInstanceType::getInstance(); |
| 160 | - } else { |
|
| 160 | + }else { |
|
| 161 | 161 | $instance = new $varInstanceType(); |
| 162 | 162 | } |
| 163 | 163 | return $instance; |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | public static function getClassProperties($class) |
| 172 | 172 | { |
| 173 | 173 | $properties = []; |
| 174 | - Logger::log('Extracting annotations properties from class ' . $class); |
|
| 174 | + Logger::log('Extracting annotations properties from class '.$class); |
|
| 175 | 175 | $selfReflector = new \ReflectionClass($class); |
| 176 | 176 | if (false !== $selfReflector->getParentClass()) { |
| 177 | 177 | $properties = self::getClassProperties($selfReflector->getParentClass()->getName()); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | public function __construct($type = 'js') |
| 36 | 36 | { |
| 37 | 37 | $this->type = $type; |
| 38 | - $this->path = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 38 | + $this->path = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 39 | 39 | $this->domains = Template::getDomains(true); |
| 40 | 40 | $this->debug = Config::getParam('debug', true); |
| 41 | 41 | $this->cdnPath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl()); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $source_file = explode("?", $source_file); |
| 59 | 59 | $source_file = $source_file[0]; |
| 60 | 60 | } |
| 61 | - $orig = realpath(dirname($filename_path) . DIRECTORY_SEPARATOR . $source_file); |
|
| 61 | + $orig = realpath(dirname($filename_path).DIRECTORY_SEPARATOR.$source_file); |
|
| 62 | 62 | return $orig; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -71,12 +71,12 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function addFile($filename) |
| 73 | 73 | { |
| 74 | - if (file_exists($this->path . $filename) && preg_match('/\.' . $this->type . '$/i', $filename)) { |
|
| 74 | + if (file_exists($this->path.$filename) && preg_match('/\.'.$this->type.'$/i', $filename)) { |
|
| 75 | 75 | $this->files[] = $filename; |
| 76 | 76 | } elseif (!empty($this->domains)) { |
| 77 | 77 | foreach ($this->domains as $domain => $paths) { |
| 78 | 78 | $domain_filename = str_replace($domain, $paths["public"], $filename); |
| 79 | - if (file_exists($domain_filename) && preg_match('/\.' . $this->type . '$/i', $domain_filename)) { |
|
| 79 | + if (file_exists($domain_filename) && preg_match('/\.'.$this->type.'$/i', $domain_filename)) { |
|
| 80 | 80 | $this->files[] = $domain_filename; |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | public function setHash($hash) |
| 94 | 94 | { |
| 95 | 95 | $cache = Config::getParam('cache.var', ''); |
| 96 | - $this->hash = $hash . (strlen($cache) ? '.' : '') . $cache; |
|
| 96 | + $this->hash = $hash.(strlen($cache) ? '.' : '').$cache; |
|
| 97 | 97 | return $this; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | protected function compileCss() |
| 129 | 129 | { |
| 130 | - $base = $this->path . "css" . DIRECTORY_SEPARATOR; |
|
| 131 | - if ($this->debug || !file_exists($base . $this->hash . ".css")) { |
|
| 130 | + $base = $this->path."css".DIRECTORY_SEPARATOR; |
|
| 131 | + if ($this->debug || !file_exists($base.$this->hash.".css")) { |
|
| 132 | 132 | $data = ''; |
| 133 | 133 | if (0 < count($this->files)) { |
| 134 | 134 | $minifier = new CSS(); |
@@ -136,15 +136,15 @@ discard block |
||
| 136 | 136 | $data = $this->processCssLine($file, $base, $data); |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | - if($this->debug) { |
|
| 140 | - $this->storeContents($base . $this->hash . ".css", $data); |
|
| 141 | - } else { |
|
| 139 | + if ($this->debug) { |
|
| 140 | + $this->storeContents($base.$this->hash.".css", $data); |
|
| 141 | + }else { |
|
| 142 | 142 | $minifier = new CSS(); |
| 143 | 143 | $minifier->add($data); |
| 144 | 144 | ini_set('max_execution_time', -1); |
| 145 | 145 | ini_set('memory_limit', -1); |
| 146 | 146 | GeneratorHelper::createDir($base); |
| 147 | - $minifier->minify($base . $this->hash . ".css"); |
|
| 147 | + $minifier->minify($base.$this->hash.".css"); |
|
| 148 | 148 | ini_restore('memory_limit'); |
| 149 | 149 | ini_restore('max_execution_time'); |
| 150 | 150 | } |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | protected function compileJs() |
| 162 | 162 | { |
| 163 | - $base = $this->path . "js" . DIRECTORY_SEPARATOR; |
|
| 164 | - if ($this->debug || !file_exists($base . $this->hash . ".js")) { |
|
| 163 | + $base = $this->path."js".DIRECTORY_SEPARATOR; |
|
| 164 | + if ($this->debug || !file_exists($base.$this->hash.".js")) { |
|
| 165 | 165 | $data = ''; |
| 166 | 166 | if (0 < count($this->files)) { |
| 167 | 167 | $minifier = new JS(); |
@@ -170,19 +170,19 @@ discard block |
||
| 170 | 170 | if (file_exists($file)) { |
| 171 | 171 | if ($this->debug) { |
| 172 | 172 | $data = $this->putDebugJs($path_parts, $base, $file); |
| 173 | - } elseif (!file_exists($base . $this->hash . ".js")) { |
|
| 173 | + } elseif (!file_exists($base.$this->hash.".js")) { |
|
| 174 | 174 | $minifier->add($file); |
| 175 | 175 | //$data = $this->putProductionJs($base, $file, $data); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | - if($this->debug) { |
|
| 180 | - $this->storeContents($base . $this->hash . ".js", $data); |
|
| 181 | - } else { |
|
| 179 | + if ($this->debug) { |
|
| 180 | + $this->storeContents($base.$this->hash.".js", $data); |
|
| 181 | + }else { |
|
| 182 | 182 | ini_set('max_execution_time', -1); |
| 183 | 183 | ini_set('memory_limit', -1); |
| 184 | 184 | GeneratorHelper::createDir($base); |
| 185 | - $minifier->minify($base . $this->hash . ".js"); |
|
| 185 | + $minifier->minify($base.$this->hash.".js"); |
|
| 186 | 186 | ini_restore('memory_limit'); |
| 187 | 187 | ini_restore('max_execution_time'); |
| 188 | 188 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | { |
| 203 | 203 | GeneratorHelper::createDir(dirname($path)); |
| 204 | 204 | if ("" !== $content && false === file_put_contents($path, $content)) { |
| 205 | - throw new ConfigException(t('No se tienen permisos para escribir en ' . $path)); |
|
| 205 | + throw new ConfigException(t('No se tienen permisos para escribir en '.$path)); |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | foreach ($this->compiled_files as $file) { |
| 232 | 232 | echo "\t\t<script type='text/javascript' src='{$file}'></script>\n"; |
| 233 | 233 | } |
| 234 | - } else { |
|
| 234 | + }else { |
|
| 235 | 235 | $basePath = $this->cdnPath ?: ''; |
| 236 | - echo "\t\t<script type='text/javascript' src='" . $basePath . "/js/" . $this->hash . ".js'></script>\n"; |
|
| 236 | + echo "\t\t<script type='text/javascript' src='".$basePath."/js/".$this->hash.".js'></script>\n"; |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | foreach ($this->compiled_files as $file) { |
| 247 | 247 | echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>"; |
| 248 | 248 | } |
| 249 | - } else { |
|
| 249 | + }else { |
|
| 250 | 250 | $basePath = $this->cdnPath ?: ''; |
| 251 | - echo "\t\t<link href='" . $basePath . "/css/" . $this->hash . ".css' rel='stylesheet'>"; |
|
| 251 | + echo "\t\t<link href='".$basePath."/css/".$this->hash.".css' rel='stylesheet'>"; |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
@@ -259,20 +259,20 @@ discard block |
||
| 259 | 259 | protected function extractCssResources($source, $file) |
| 260 | 260 | { |
| 261 | 261 | $source_file = $this->extractSourceFilename($source); |
| 262 | - $orig = realpath(dirname($file) . DIRECTORY_SEPARATOR . $source_file); |
|
| 262 | + $orig = realpath(dirname($file).DIRECTORY_SEPARATOR.$source_file); |
|
| 263 | 263 | $orig_part = preg_split('/(\/|\\\)public(\/|\\\)/i', $orig); |
| 264 | 264 | try { |
| 265 | 265 | if (count($source) > 1 && array_key_exists(1, $orig_part)) { |
| 266 | - $dest = $this->path . $orig_part[1]; |
|
| 266 | + $dest = $this->path.$orig_part[1]; |
|
| 267 | 267 | GeneratorHelper::createDir(dirname($dest)); |
| 268 | 268 | if (!file_exists($dest) || filemtime($orig) > filemtime($dest)) { |
| 269 | 269 | if (@copy($orig, $dest) === FALSE) { |
| 270 | - throw new \RuntimeException('Can\' copy ' . $dest . ''); |
|
| 270 | + throw new \RuntimeException('Can\' copy '.$dest.''); |
|
| 271 | 271 | } |
| 272 | 272 | Logger::log("$orig copiado a $dest", LOG_INFO); |
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | - } catch (\Exception $e) { |
|
| 275 | + }catch (\Exception $e) { |
|
| 276 | 276 | Logger::log($e->getMessage(), LOG_ERR); |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -289,21 +289,21 @@ discard block |
||
| 289 | 289 | { |
| 290 | 290 | if (file_exists($file)) { |
| 291 | 291 | $path_parts = explode("/", $file); |
| 292 | - $file_path = $this->hash . "_" . $path_parts[count($path_parts) - 1]; |
|
| 293 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($file) || $this->debug) { |
|
| 292 | + $file_path = $this->hash."_".$path_parts[count($path_parts) - 1]; |
|
| 293 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($file) || $this->debug) { |
|
| 294 | 294 | //Si tenemos modificaciones tenemos que compilar de nuevo todos los ficheros modificados |
| 295 | - if (file_exists($base . $this->hash . ".css") && @unlink($base . $this->hash . ".css") === false) { |
|
| 296 | - throw new ConfigException("Can't unlink file " . $base . $this->hash . ".css"); |
|
| 295 | + if (file_exists($base.$this->hash.".css") && @unlink($base.$this->hash.".css") === false) { |
|
| 296 | + throw new ConfigException("Can't unlink file ".$base.$this->hash.".css"); |
|
| 297 | 297 | } |
| 298 | 298 | $this->loopCssLines($file); |
| 299 | 299 | } |
| 300 | 300 | if ($this->debug) { |
| 301 | 301 | $data = file_get_contents($file); |
| 302 | - $this->storeContents($base . $file_path, $data); |
|
| 303 | - } else { |
|
| 302 | + $this->storeContents($base.$file_path, $data); |
|
| 303 | + }else { |
|
| 304 | 304 | $data .= file_get_contents($file); |
| 305 | 305 | } |
| 306 | - $this->compiled_files[] = "/css/" . $file_path; |
|
| 306 | + $this->compiled_files[] = "/css/".$file_path; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | return $data; |
@@ -318,12 +318,12 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | protected function putDebugJs($path_parts, $base, $file) |
| 320 | 320 | { |
| 321 | - $file_path = $this->hash . "_" . $path_parts[count($path_parts) - 1]; |
|
| 322 | - $this->compiled_files[] = "/js/" . $file_path; |
|
| 321 | + $file_path = $this->hash."_".$path_parts[count($path_parts) - 1]; |
|
| 322 | + $this->compiled_files[] = "/js/".$file_path; |
|
| 323 | 323 | $data = ""; |
| 324 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($file)) { |
|
| 324 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($file)) { |
|
| 325 | 325 | $data = file_get_contents($file); |
| 326 | - $this->storeContents($base . $file_path, $data); |
|
| 326 | + $this->storeContents($base.$file_path, $data); |
|
| 327 | 327 | } |
| 328 | 328 | return $data; |
| 329 | 329 | } |
@@ -365,60 +365,60 @@ discard block |
||
| 365 | 365 | { |
| 366 | 366 | $ppath = explode("/", $string); |
| 367 | 367 | $original_filename = $ppath[count($ppath) - 1]; |
| 368 | - $base = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 368 | + $base = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 369 | 369 | $file = ""; |
| 370 | 370 | $html_base = ""; |
| 371 | 371 | $debug = Config::getInstance()->getDebugMode(); |
| 372 | 372 | $cache = Config::getInstance()->get('cache.var'); |
| 373 | - $cache = $cache ? '.' . $cache : ''; |
|
| 373 | + $cache = $cache ? '.'.$cache : ''; |
|
| 374 | 374 | $finfo = finfo_open(FILEINFO_MIME_TYPE); // devuelve el tipo mime de su extensión |
| 375 | 375 | $mime = finfo_file($finfo, $filename_path); |
| 376 | 376 | finfo_close($finfo); |
| 377 | 377 | if (preg_match('/\.css$/i', $string)) { |
| 378 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.css"; |
|
| 378 | + $file = "/".substr(md5($string), 0, 8)."$cache.css"; |
|
| 379 | 379 | $html_base = "css"; |
| 380 | 380 | if ($debug) { |
| 381 | - $file = str_replace(".css", "_" . $original_filename, $file); |
|
| 381 | + $file = str_replace(".css", "_".$original_filename, $file); |
|
| 382 | 382 | } |
| 383 | 383 | } elseif (preg_match('/\.js$/i', $string)) { |
| 384 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.js"; |
|
| 384 | + $file = "/".substr(md5($string), 0, 8)."$cache.js"; |
|
| 385 | 385 | $html_base = "js"; |
| 386 | 386 | if ($debug) { |
| 387 | - $file = str_replace(".js", "_" . $original_filename, $file); |
|
| 387 | + $file = str_replace(".js", "_".$original_filename, $file); |
|
| 388 | 388 | } |
| 389 | 389 | } elseif (preg_match("/image/i", $mime)) { |
| 390 | 390 | $ext = explode(".", $string); |
| 391 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 391 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 392 | 392 | $html_base = "img"; |
| 393 | 393 | if ($debug) { |
| 394 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 394 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 395 | 395 | } |
| 396 | 396 | } elseif (preg_match("/(doc|pdf)/i", $mime)) { |
| 397 | 397 | $ext = explode(".", $string); |
| 398 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 398 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 399 | 399 | $html_base = "docs"; |
| 400 | 400 | if ($debug) { |
| 401 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 401 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 402 | 402 | } |
| 403 | 403 | } elseif (preg_match("/(video|audio|ogg)/i", $mime)) { |
| 404 | 404 | $ext = explode(".", $string); |
| 405 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 405 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 406 | 406 | $html_base = "media"; |
| 407 | 407 | if ($debug) { |
| 408 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 408 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 409 | 409 | } |
| 410 | 410 | } elseif (preg_match("/(text|html)/i", $mime)) { |
| 411 | 411 | $ext = explode(".", $string); |
| 412 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 412 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 413 | 413 | $html_base = "templates"; |
| 414 | 414 | if ($debug) { |
| 415 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 415 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 416 | 416 | } |
| 417 | 417 | } elseif (!$return && !is_null($name)) { |
| 418 | 418 | $html_base = ''; |
| 419 | 419 | $file = $name; |
| 420 | 420 | } |
| 421 | - $file_path = $html_base . $file; |
|
| 421 | + $file_path = $html_base.$file; |
|
| 422 | 422 | |
| 423 | 423 | return array($base, $html_base, $file_path); |
| 424 | 424 | } |
@@ -436,15 +436,15 @@ discard block |
||
| 436 | 436 | if (preg_match_all('#url\((.*?)\)#', $line, $urls, PREG_SET_ORDER)) { |
| 437 | 437 | foreach ($urls as $source) { |
| 438 | 438 | $orig = self::calculateResourcePathname($filename_path, $source); |
| 439 | - if(!empty($orig)) { |
|
| 439 | + if (!empty($orig)) { |
|
| 440 | 440 | $orig_part = preg_split("/Public/i", $orig); |
| 441 | - $dest = WEB_DIR . $orig_part[1]; |
|
| 441 | + $dest = WEB_DIR.$orig_part[1]; |
|
| 442 | 442 | GeneratorHelper::createDir(dirname($dest)); |
| 443 | 443 | if (@copy($orig, $dest) === false) { |
| 444 | - throw new ConfigException("Can't copy " . $orig . " to " . $dest); |
|
| 444 | + throw new ConfigException("Can't copy ".$orig." to ".$dest); |
|
| 445 | 445 | } |
| 446 | - } else { |
|
| 447 | - Logger::log($filename_path . ' has an empty origin with the url ' . $source, LOG_WARNING); |
|
| 446 | + }else { |
|
| 447 | + Logger::log($filename_path.' has an empty origin with the url '.$source, LOG_WARNING); |
|
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | )) |
| 38 | 38 | ->addButton('submit', t("Acceder como {{username}}")) |
| 39 | 39 | ->addButton("cancel", t("Cancelar"), "button", array( |
| 40 | - "onclick" => "javacript:location.href = \"" . Router::getInstance()->getRoute('') . "\";", |
|
| 40 | + "onclick" => "javacript:location.href = \"".Router::getInstance()->getRoute('')."\";", |
|
| 41 | 41 | "class" => "btn-link", |
| 42 | 42 | )); |
| 43 | 43 | } |
@@ -83,9 +83,9 @@ |
||
| 83 | 83 | 'class' => 'btn-warning md-default', |
| 84 | 84 | 'icon' => 'fa-plus', |
| 85 | 85 | ]; |
| 86 | - if(Config::getParam('admin.version', 'v1') === 'v1') { |
|
| 87 | - $add['onclick'] = 'javascript:addNewField(document.getElementById("' . $this->getName() . '"));'; |
|
| 88 | - } else { |
|
| 86 | + if (Config::getParam('admin.version', 'v1') === 'v1') { |
|
| 87 | + $add['onclick'] = 'javascript:addNewField(document.getElementById("'.$this->getName().'"));'; |
|
| 88 | + }else { |
|
| 89 | 89 | $add['ng-click'] = 'addNewField()'; |
| 90 | 90 | } |
| 91 | 91 | $this->addButton('submit', t('Guardar configuración'), 'submit', array( |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function init() |
| 76 | 76 | { |
| 77 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE); |
|
| 77 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE); |
|
| 78 | 78 | if (empty($this->routing) || Config::getParam('debug', true)) { |
| 79 | 79 | $this->debugLoad(); |
| 80 | - } else { |
|
| 81 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE); |
|
| 80 | + }else { |
|
| 81 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE); |
|
| 82 | 82 | } |
| 83 | 83 | $this->checkExternalModules(false); |
| 84 | 84 | $this->setLoaded(); |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | $notFoundRoute = Config::getParam('route.404'); |
| 119 | - if(null !== $notFoundRoute) { |
|
| 119 | + if (null !== $notFoundRoute) { |
|
| 120 | 120 | Request::getInstance()->redirect($this->getRoute($notFoundRoute, true)); |
| 121 | - } else { |
|
| 121 | + }else { |
|
| 122 | 122 | return $template->render('error.html.twig', array( |
| 123 | 123 | 'exception' => $exception, |
| 124 | 124 | 'trace' => $exception->getTraceAsString(), |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | try { |
| 170 | 170 | //Search action and execute |
| 171 | 171 | return $this->searchAction($route); |
| 172 | - } catch (AccessDeniedException $e) { |
|
| 173 | - Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
| 172 | + }catch (AccessDeniedException $e) { |
|
| 173 | + Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
| 174 | 174 | return Admin::staticAdminLogon($route); |
| 175 | - } catch (RouterException $r) { |
|
| 175 | + }catch (RouterException $r) { |
|
| 176 | 176 | Logger::log($r->getMessage(), LOG_WARNING); |
| 177 | - } catch (\Exception $e) { |
|
| 177 | + }catch (\Exception $e) { |
|
| 178 | 178 | Logger::log($e->getMessage(), LOG_ERR); |
| 179 | 179 | throw $e; |
| 180 | 180 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | protected function searchAction($route) |
| 194 | 194 | { |
| 195 | - Logger::log('Searching action to execute: ' . $route, LOG_INFO); |
|
| 195 | + Logger::log('Searching action to execute: '.$route, LOG_INFO); |
|
| 196 | 196 | //Revisamos si tenemos la ruta registrada |
| 197 | 197 | $parts = parse_url($route); |
| 198 | 198 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -207,12 +207,12 @@ discard block |
||
| 207 | 207 | /** @var $class \PSFS\base\types\Controller */ |
| 208 | 208 | $class = RouterHelper::getClassToCall($action); |
| 209 | 209 | try { |
| 210 | - if($this->checkRequirements($action, $get)) { |
|
| 210 | + if ($this->checkRequirements($action, $get)) { |
|
| 211 | 211 | return $this->executeCachedRoute($route, $action, $class, $get); |
| 212 | - } else { |
|
| 212 | + }else { |
|
| 213 | 213 | throw new RouterException(t('La ruta no es válida'), 400); |
| 214 | 214 | } |
| 215 | - } catch (\Exception $e) { |
|
| 215 | + }catch (\Exception $e) { |
|
| 216 | 216 | Logger::log($e->getMessage(), LOG_ERR); |
| 217 | 217 | throw $e; |
| 218 | 218 | } |
@@ -227,15 +227,15 @@ discard block |
||
| 227 | 227 | * @return bool |
| 228 | 228 | */ |
| 229 | 229 | private function checkRequirements(array $action, $params = []) { |
| 230 | - if(!empty($params) && !empty($action['requirements'])) { |
|
| 230 | + if (!empty($params) && !empty($action['requirements'])) { |
|
| 231 | 231 | $checked = 0; |
| 232 | - foreach(array_keys($params) as $key) { |
|
| 233 | - if(in_array($key, $action['requirements'], true)) { |
|
| 232 | + foreach (array_keys($params) as $key) { |
|
| 233 | + if (in_array($key, $action['requirements'], true)) { |
|
| 234 | 234 | $checked++; |
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | $valid = count($action['requirements']) === $checked; |
| 238 | - } else { |
|
| 238 | + }else { |
|
| 239 | 239 | $valid = true; |
| 240 | 240 | } |
| 241 | 241 | return $valid; |
@@ -285,14 +285,14 @@ discard block |
||
| 285 | 285 | $this->checkExternalModules(); |
| 286 | 286 | if (file_exists($modulesPath)) { |
| 287 | 287 | $modules = $this->finder->directories()->in($modulesPath)->depth(0); |
| 288 | - if($modules->hasResults()) { |
|
| 288 | + if ($modules->hasResults()) { |
|
| 289 | 289 | foreach ($modules->getIterator() as $modulePath) { |
| 290 | 290 | $module = $modulePath->getBasename(); |
| 291 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
| 291 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE); |
|
| 295 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | $home_params = NULL; |
| 309 | 309 | foreach ($this->routing as $pattern => $params) { |
| 310 | 310 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
| 311 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
| 311 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
| 312 | 312 | $home_params = $params; |
| 313 | 313 | } |
| 314 | 314 | unset($method); |
@@ -330,14 +330,14 @@ discard block |
||
| 330 | 330 | private function inspectDir($origen, $namespace = 'PSFS', $routing = []) |
| 331 | 331 | { |
| 332 | 332 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name('*.php'); |
| 333 | - if($files->hasResults()) { |
|
| 333 | + if ($files->hasResults()) { |
|
| 334 | 334 | foreach ($files->getIterator() as $file) { |
| 335 | - if($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) { |
|
| 336 | - $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
| 337 | - } else { |
|
| 335 | + if ($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) { |
|
| 336 | + $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
| 337 | + }else { |
|
| 338 | 338 | $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname())); |
| 339 | 339 | } |
| 340 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
| 340 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | $this->finder = new Finder(); |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | private function addRouting($namespace, &$routing, $module = 'PSFS') |
| 367 | 367 | { |
| 368 | 368 | if (self::exists($namespace)) { |
| 369 | - if(I18nHelper::checkI18Class($namespace)) { |
|
| 369 | + if (I18nHelper::checkI18Class($namespace)) { |
|
| 370 | 370 | return $routing; |
| 371 | 371 | } |
| 372 | 372 | $reflection = new \ReflectionClass($namespace); |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | if (!$this->domains) { |
| 409 | 409 | $this->domains = []; |
| 410 | 410 | } |
| 411 | - $domain = '@' . $class->getConstant('DOMAIN') . '/'; |
|
| 411 | + $domain = '@'.$class->getConstant('DOMAIN').'/'; |
|
| 412 | 412 | if (!array_key_exists($domain, $this->domains)) { |
| 413 | 413 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
| 414 | 414 | } |
@@ -424,11 +424,11 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | public function simpatize() |
| 426 | 426 | { |
| 427 | - $translationFileName = 'translations' . DIRECTORY_SEPARATOR . 'routes_translations.php'; |
|
| 428 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
| 427 | + $translationFileName = 'translations'.DIRECTORY_SEPARATOR.'routes_translations.php'; |
|
| 428 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
| 429 | 429 | $this->generateSlugs($absoluteTranslationFileName); |
| 430 | 430 | GeneratorHelper::createDir(CONFIG_DIR); |
| 431 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
| 431 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
| 432 | 432 | |
| 433 | 433 | return $this; |
| 434 | 434 | } |
@@ -444,18 +444,18 @@ discard block |
||
| 444 | 444 | public function getRoute($slug = '', $absolute = FALSE, array $params = []) |
| 445 | 445 | { |
| 446 | 446 | if ('' === $slug) { |
| 447 | - return $absolute ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
| 447 | + return $absolute ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
| 448 | 448 | } |
| 449 | 449 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
| 450 | 450 | throw new RouterException(t('No existe la ruta especificada')); |
| 451 | 451 | } |
| 452 | - $url = $absolute ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
| 452 | + $url = $absolute ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
| 453 | 453 | if (!empty($params)) { |
| 454 | 454 | foreach ($params as $key => $value) { |
| 455 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
| 455 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
| 456 | 456 | } |
| 457 | 457 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
| 458 | - $url = $absolute ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default']; |
|
| 458 | + $url = $absolute ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default']; |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -474,15 +474,15 @@ discard block |
||
| 474 | 474 | * @param string $method |
| 475 | 475 | */ |
| 476 | 476 | private function checkPreActions($class, $method) { |
| 477 | - $preAction = 'pre' . ucfirst($method); |
|
| 478 | - if(method_exists($class, $preAction)) { |
|
| 477 | + $preAction = 'pre'.ucfirst($method); |
|
| 478 | + if (method_exists($class, $preAction)) { |
|
| 479 | 479 | Logger::log(t('Pre action invoked')); |
| 480 | 480 | try { |
| 481 | - if(false === call_user_func_array([$class, $preAction])) { |
|
| 481 | + if (false === call_user_func_array([$class, $preAction])) { |
|
| 482 | 482 | Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]); |
| 483 | 483 | error_clear_last(); |
| 484 | 484 | } |
| 485 | - } catch (\Exception $e) { |
|
| 485 | + }catch (\Exception $e) { |
|
| 486 | 486 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
| 487 | 487 | } |
| 488 | 488 | } |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | */ |
| 500 | 500 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
| 501 | 501 | { |
| 502 | - Logger::log('Executing route ' . $route, LOG_INFO); |
|
| 502 | + Logger::log('Executing route '.$route, LOG_INFO); |
|
| 503 | 503 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
| 504 | 504 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
| 505 | 505 | $cache = Cache::needCache(); |
@@ -507,9 +507,9 @@ discard block |
||
| 507 | 507 | $return = null; |
| 508 | 508 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
| 509 | 509 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
| 510 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
| 510 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
| 511 | 511 | if (NULL !== $cachedData) { |
| 512 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
| 512 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
| 513 | 513 | Template::getInstance()->renderCache($cachedData, $headers); |
| 514 | 514 | $execute = FALSE; |
| 515 | 515 | } |
@@ -554,11 +554,11 @@ discard block |
||
| 554 | 554 | private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath) |
| 555 | 555 | { |
| 556 | 556 | $extModule = $modulePath->getBasename(); |
| 557 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
| 558 | - if(file_exists($moduleAutoloader)) { |
|
| 557 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
| 558 | + if (file_exists($moduleAutoloader)) { |
|
| 559 | 559 | include_once $moduleAutoloader; |
| 560 | 560 | if ($hydrateRoute) { |
| 561 | - $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing); |
|
| 561 | + $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing); |
|
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | } |
@@ -572,16 +572,16 @@ discard block |
||
| 572 | 572 | { |
| 573 | 573 | try { |
| 574 | 574 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
| 575 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
| 576 | - if(file_exists($externalModulePath)) { |
|
| 575 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
| 576 | + if (file_exists($externalModulePath)) { |
|
| 577 | 577 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
| 578 | - if($externalModule->hasResults()) { |
|
| 578 | + if ($externalModule->hasResults()) { |
|
| 579 | 579 | foreach ($externalModule->getIterator() as $modulePath) { |
| 580 | 580 | $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath); |
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | 583 | } |
| 584 | - } catch (\Exception $e) { |
|
| 584 | + }catch (\Exception $e) { |
|
| 585 | 585 | Logger::log($e->getMessage(), LOG_WARNING); |
| 586 | 586 | $module = null; |
| 587 | 587 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public static function header($name, $default = null) |
| 147 | 147 | { |
| 148 | - return self::getInstance()->getHeader($name, $default); |
|
| 148 | + return self::getInstance()->getHeader($name, $default); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -158,10 +158,10 @@ discard block |
||
| 158 | 158 | $header = null; |
| 159 | 159 | if ($this->hasHeader($name)) { |
| 160 | 160 | $header = $this->header[$name]; |
| 161 | - } else if(array_key_exists('h_' . strtolower($name), $this->query)) { |
|
| 162 | - $header = $this->query['h_' . strtolower($name)]; |
|
| 163 | - } else if(array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
| 164 | - $header = $this->server['HTTP_' . strtoupper(str_replace('-', '_', $name))]; |
|
| 161 | + }else if (array_key_exists('h_'.strtolower($name), $this->query)) { |
|
| 162 | + $header = $this->query['h_'.strtolower($name)]; |
|
| 163 | + }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
| 164 | + $header = $this->server['HTTP_'.strtoupper(str_replace('-', '_', $name))]; |
|
| 165 | 165 | } |
| 166 | 166 | return $header ?: $default; |
| 167 | 167 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | $url = $this->getServer('HTTP_ORIGIN'); |
| 261 | 261 | } |
| 262 | 262 | ob_start(); |
| 263 | - header('Location: ' . $url); |
|
| 263 | + header('Location: '.$url); |
|
| 264 | 264 | ob_end_clean(); |
| 265 | 265 | Security::getInstance()->updateSession(); |
| 266 | 266 | exit(t('Redireccionando...')); |
@@ -306,10 +306,10 @@ discard block |
||
| 306 | 306 | $url = $this->getServerName(); |
| 307 | 307 | $protocol = $hasProtocol ? $this->getProtocol() : ''; |
| 308 | 308 | if (!empty($protocol)) { |
| 309 | - $url = $protocol . $url; |
|
| 309 | + $url = $protocol.$url; |
|
| 310 | 310 | } |
| 311 | 311 | if (!in_array((integer)$this->getServer('SERVER_PORT'), [80, 443], true)) { |
| 312 | - $url .= ':' . $this->getServer('SERVER_PORT'); |
|
| 312 | + $url .= ':'.$this->getServer('SERVER_PORT'); |
|
| 313 | 313 | } |
| 314 | 314 | return $url; |
| 315 | 315 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | GeneratorHelper::createDir(dirname($path)); |
| 56 | 56 | if (false === FileHelper::writeFile($path, $data)) { |
| 57 | - throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ') . $path); |
|
| 57 | + throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ').$path); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | Logger::log('Gathering data from cache', LOG_DEBUG, ['path' => $path]); |
| 70 | 70 | $data = null; |
| 71 | - $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
| 71 | + $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
| 72 | 72 | if (file_exists($absolutePath)) { |
| 73 | 73 | $data = FileHelper::readFile($absolutePath); |
| 74 | 74 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
| 85 | 85 | { |
| 86 | 86 | Logger::log('Checking expiration', LOG_DEBUG, ['path' => $path]); |
| 87 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
| 87 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
| 88 | 88 | $lasModificationDate = filemtime($absolutePath); |
| 89 | 89 | return ($lasModificationDate + $expires <= time()); |
| 90 | 90 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | { |
| 152 | 152 | Logger::log('Store data in cache', LOG_DEBUG, ['path' => $path]); |
| 153 | 153 | $data = self::transformData($data, $transform); |
| 154 | - $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
| 154 | + $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
| 155 | 155 | $this->saveTextToFile($data, $absolutePath); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | { |
| 169 | 169 | $data = null; |
| 170 | 170 | Logger::log('Reading data from cache', LOG_DEBUG, ['path' => $path]); |
| 171 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) { |
|
| 171 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) { |
|
| 172 | 172 | if (is_callable($function) && $this->hasExpiredCache($path, $expires)) { |
| 173 | 173 | $data = $function(); |
| 174 | 174 | $this->storeData($path, $data, $transform, false, $expires); |
| 175 | - } else { |
|
| 175 | + }else { |
|
| 176 | 176 | $data = $this->getDataFromFile($path, $transform); |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -224,13 +224,13 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | public function flushCache() { |
| 227 | - if(Config::getParam('cache.data.enable', false)) { |
|
| 227 | + if (Config::getParam('cache.data.enable', false)) { |
|
| 228 | 228 | Logger::log('Flushing cache', LOG_DEBUG); |
| 229 | 229 | $action = Security::getInstance()->getSessionKey(self::CACHE_SESSION_VAR); |
| 230 | - if(is_array($action)) { |
|
| 231 | - $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
| 232 | - if(!file_exists($hashPath)) { |
|
| 233 | - $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath; |
|
| 230 | + if (is_array($action)) { |
|
| 231 | + $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
| 232 | + if (!file_exists($hashPath)) { |
|
| 233 | + $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath; |
|
| 234 | 234 | } |
| 235 | 235 | FileHelper::deleteDir($hashPath); |
| 236 | 236 | } |