@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | && (preg_match('/^\/(admin|setup\-admin)/i', $route) || Config::getParam('restricted', false)) |
35 | 35 | ) { |
36 | 36 | if (!self::isTest() && |
37 | - null === Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true)) { |
|
37 | + null === Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true)) { |
|
38 | 38 | throw new AdminCredentialsException(); |
39 | 39 | } |
40 | 40 | if (!Security::getInstance()->checkAdmin()) { |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | $token = ''; |
55 | 55 | $length = strlen($timestamp); |
56 | 56 | for ($i = 0; $i < $length; $i++) { |
57 | - $token = substr($hash, $i, 1) . |
|
58 | - substr($timestamp, $i, 1) . |
|
57 | + $token = substr($hash, $i, 1). |
|
58 | + substr($timestamp, $i, 1). |
|
59 | 59 | $token; |
60 | 60 | } |
61 | 61 | return $token; |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | $charsLength = strlen(self::RAND_SEP) - 1; |
75 | 75 | $tsLength = strlen($timestamp); |
76 | 76 | $i = 0; |
77 | - $partCount = ceil($hashRest / 4); |
|
78 | - $part = substr($hash, $tsLength + $partCount * $i, $partCount); |
|
77 | + $partCount = ceil($hashRest/4); |
|
78 | + $part = substr($hash, $tsLength + $partCount*$i, $partCount); |
|
79 | 79 | while (false !== $part && strlen($part) > 0) { |
80 | - $mixedToken .= $part . |
|
81 | - substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1) . |
|
80 | + $mixedToken .= $part. |
|
81 | + substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1). |
|
82 | 82 | substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1); |
83 | - $part = substr($hash, $tsLength + $partCount * $i, $partCount); |
|
83 | + $part = substr($hash, $tsLength + $partCount*$i, $partCount); |
|
84 | 84 | $i++; |
85 | 85 | } |
86 | - return $mixedToken . $token; |
|
86 | + return $mixedToken.$token; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | private static function getTs($isOdd = null) |
94 | 94 | { |
95 | 95 | $timestamp = time(); |
96 | - $tsIsOdd = (bool)((int)substr($timestamp, -1) % 2); |
|
96 | + $tsIsOdd = (bool)((int)substr($timestamp, -1)%2); |
|
97 | 97 | if (false === $isOdd && !$tsIsOdd) { |
98 | 98 | $timestamp--; |
99 | 99 | } elseif (true === $isOdd && !$tsIsOdd) { |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | $timestamp = ''; |
130 | 130 | $part = strrev($part); |
131 | 131 | for ($i = 0, $ct = strlen($part); $i < $ct; $i++) { |
132 | - if ($i % 2 == 0) { |
|
132 | + if ($i%2 == 0) { |
|
133 | 133 | $timestamp .= substr($part, $i, 1); |
134 | - } else { |
|
134 | + }else { |
|
135 | 135 | $partToken .= substr($part, $i, 1); |
136 | 136 | } |
137 | 137 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | list($partToken, $timestamp) = self::extractTs(array_pop($parts)); |
149 | 149 | $token = null; |
150 | 150 | if ($timestamp > 0) { |
151 | - $token = $partToken . implode('', $parts); |
|
151 | + $token = $partToken.implode('', $parts); |
|
152 | 152 | } |
153 | 153 | return [$token, $timestamp]; |
154 | 154 | } |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | { |
25 | 25 | Inspector::stats('[RouterHelper] Getting class to call for executing the request action', Inspector::SCOPE_DEBUG); |
26 | 26 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
27 | - $actionClass = class_exists($action['class']) ? $action['class'] : "\\" . $action['class']; |
|
27 | + $actionClass = class_exists($action['class']) ? $action['class'] : "\\".$action['class']; |
|
28 | 28 | $reflectionClass = new ReflectionClass($actionClass); |
29 | 29 | if ($reflectionClass->hasMethod('getInstance')) { |
30 | 30 | $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']); |
31 | - } else { |
|
31 | + }else { |
|
32 | 32 | $class = new $actionClass; |
33 | 33 | } |
34 | 34 | return $class; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public static function extractComponents($route, $pattern) |
63 | 63 | { |
64 | 64 | Inspector::stats('[RouterHelper] Extracting parts for the request to execute', Inspector::SCOPE_DEBUG); |
65 | - if(Config::getParam('allow.double.slashes', true)) { |
|
65 | + if (Config::getParam('allow.double.slashes', true)) { |
|
66 | 66 | $route = preg_replace("/\/\//", '/', $route); |
67 | 67 | } |
68 | 68 | $url = parse_url($route); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $cleanPatternSep--; |
101 | 101 | } |
102 | 102 | |
103 | - if(Config::getParam('allow.double.slashes', true)) { |
|
103 | + if (Config::getParam('allow.double.slashes', true)) { |
|
104 | 104 | $path = preg_replace("/\/\//", '/', $path); |
105 | 105 | } |
106 | 106 | $pathSep = count(explode('/', $path)); |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public static function matchRoutePattern($routePattern, $path) |
122 | 122 | { |
123 | - if(Config::getParam('allow.double.slashes', true)) { |
|
123 | + if (Config::getParam('allow.double.slashes', true)) { |
|
124 | 124 | $path = preg_replace("/\/\//", '/', $path); |
125 | 125 | } |
126 | 126 | $expr = preg_replace('/\{([^}]+)\}/', '%%%', $routePattern); |
127 | 127 | $expr = preg_quote($expr, '/'); |
128 | 128 | $expr = str_replace('%%%', '(.*)', $expr); |
129 | 129 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
130 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
130 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
131 | 131 | return $matched; |
132 | 132 | } |
133 | 133 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public static function extractDomainInfo(ReflectionClass $class, $domain) |
140 | 140 | { |
141 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
141 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
142 | 142 | $templatesPath = 'templates'; |
143 | 143 | $publicPath = 'public'; |
144 | 144 | $modelsPath = 'models'; |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | $modelsPath = ucfirst($modelsPath); |
149 | 149 | } |
150 | 150 | if ($class->hasConstant('TPL')) { |
151 | - $templatesPath .= DIRECTORY_SEPARATOR . $class->getConstant('TPL'); |
|
151 | + $templatesPath .= DIRECTORY_SEPARATOR.$class->getConstant('TPL'); |
|
152 | 152 | } |
153 | 153 | return [ |
154 | 154 | 'base' => $path, |
155 | - 'template' => $path . $templatesPath, |
|
156 | - 'model' => $path . $modelsPath, |
|
157 | - 'public' => $path . $publicPath, |
|
155 | + 'template' => $path.$templatesPath, |
|
156 | + 'model' => $path.$modelsPath, |
|
157 | + 'public' => $path.$publicPath, |
|
158 | 158 | ]; |
159 | 159 | } |
160 | 160 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | foreach ($parameters as $param) { |
176 | 176 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
177 | 177 | $params[$param->getName()] = $param->getDefaultValue(); |
178 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue() ?: '', $regex ?: ''); |
|
178 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue() ?: '', $regex ?: ''); |
|
179 | 179 | } elseif (!$param->isOptional()) { |
180 | 180 | $requirements[] = $param->getName(); |
181 | 181 | } |
182 | 182 | } |
183 | - } else { |
|
183 | + }else { |
|
184 | 184 | $default = $regex; |
185 | 185 | } |
186 | 186 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $httpMethod = AnnotationHelper::extractReflectionHttpMethod($docComments); |
211 | 211 | $icon = AnnotationHelper::extractDocIcon($docComments); |
212 | 212 | $label = AnnotationHelper::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
213 | - $route = $httpMethod . "#|#" . $regex; |
|
213 | + $route = $httpMethod."#|#".$regex; |
|
214 | 214 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
215 | 215 | $info = [ |
216 | 216 | 'method' => $method->getName(), |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | */ |
23 | 23 | private function getPropelPaths($modulePath) |
24 | 24 | { |
25 | - $moduleDir = CORE_DIR . DIRECTORY_SEPARATOR . $modulePath; |
|
25 | + $moduleDir = CORE_DIR.DIRECTORY_SEPARATOR.$modulePath; |
|
26 | 26 | GeneratorHelper::createDir($moduleDir); |
27 | 27 | $moduleDir = realpath($moduleDir); |
28 | - $configDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config'; |
|
29 | - $sqlDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Sql'; |
|
30 | - $migrationDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Migrations'; |
|
28 | + $configDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'; |
|
29 | + $sqlDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Sql'; |
|
30 | + $migrationDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Migrations'; |
|
31 | 31 | $paths = [ |
32 | 32 | 'projectDir' => $moduleDir, |
33 | 33 | 'outputDir' => $moduleDir, |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | * @param AbstractManager $manager |
91 | 91 | * @param string $workingDir |
92 | 92 | */ |
93 | - private function setupManager(GeneratorConfig $configGenerator, AbstractManager &$manager, $workingDir = CORE_DIR) |
|
93 | + private function setupManager(GeneratorConfig $configGenerator, AbstractManager & $manager, $workingDir = CORE_DIR) |
|
94 | 94 | { |
95 | 95 | $manager->setGeneratorConfig($configGenerator); |
96 | - $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'] . DIRECTORY_SEPARATOR . 'schema.xml'); |
|
96 | + $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'].DIRECTORY_SEPARATOR.'schema.xml'); |
|
97 | 97 | $manager->setSchemas([$schemaFile]); |
98 | - $manager->setLoggerClosure(function ($message) { |
|
98 | + $manager->setLoggerClosure(function($message) { |
|
99 | 99 | Logger::log($message, LOG_INFO); |
100 | 100 | }); |
101 | 101 | $manager->setWorkingDirectory($workingDir); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $fDto->entity = $relatedModel; |
32 | 32 | $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName()); |
33 | 33 | $fDto->relatedField = $relatedField->getPhpName(); |
34 | - $fDto->url = Router::getInstance()->getRoute(strtolower($domain) . '-api-' . $relatedModel); |
|
34 | + $fDto->url = Router::getInstance()->getRoute(strtolower($domain).'-api-'.$relatedModel); |
|
35 | 35 | return $fDto; |
36 | 36 | } |
37 | 37 | |
@@ -40,21 +40,21 @@ discard block |
||
40 | 40 | * @param ModelCriteria $query |
41 | 41 | * @param mixed $value |
42 | 42 | */ |
43 | - private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) |
|
43 | + private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null) |
|
44 | 44 | { |
45 | 45 | $tableField = $column->getFullyQualifiedName(); |
46 | - if(is_array($value)) { |
|
46 | + if (is_array($value)) { |
|
47 | 47 | $query->add($tableField, $value, Criteria::IN); |
48 | 48 | } elseif (preg_match('/^\[/', $value) && preg_match('/\]$/', $value)) { |
49 | 49 | $query->add($tableField, explode(',', preg_replace('/(\[|\])/', '', $value)), Criteria::IN); |
50 | 50 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
51 | 51 | $text = preg_replace('/(\'|\")/', '', $value); |
52 | 52 | $text = preg_replace('/\ /', '%', $text); |
53 | - $query->add($tableField, '%' . $text . '%', Criteria::LIKE); |
|
54 | - } else { |
|
55 | - if(null !== $column->getValueSet()) { |
|
53 | + $query->add($tableField, '%'.$text.'%', Criteria::LIKE); |
|
54 | + }else { |
|
55 | + if (null !== $column->getValueSet()) { |
|
56 | 56 | $valueSet = $column->getValueSet(); |
57 | - if(in_array($value, $valueSet)) { |
|
57 | + if (in_array($value, $valueSet)) { |
|
58 | 58 | $value = array_search($value, $valueSet); |
59 | 59 | } |
60 | 60 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param string $field |
70 | 70 | * @param mixed $value |
71 | 71 | */ |
72 | - public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null) |
|
72 | + public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null) |
|
73 | 73 | { |
74 | 74 | if ($column = self::checkFieldExists($tableMap, $field)) { |
75 | 75 | self::addQueryFilter($column, $query, $value); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public static function extractQuery($modelNameNamespace, ConnectionInterface $con = null) |
86 | 86 | { |
87 | - $queryReflector = new \ReflectionClass($modelNameNamespace . "Query"); |
|
87 | + $queryReflector = new \ReflectionClass($modelNameNamespace."Query"); |
|
88 | 88 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
89 | 89 | $query = $queryReflector->getMethod('create')->invoke($con); |
90 | 90 | |
@@ -97,37 +97,37 @@ discard block |
||
97 | 97 | * @param array $extraColumns |
98 | 98 | * @param mixed $value |
99 | 99 | */ |
100 | - public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null) |
|
100 | + public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null) |
|
101 | 101 | { |
102 | 102 | $exp = 'CONCAT('; |
103 | 103 | $sep = ''; |
104 | 104 | foreach ($tableMap->getColumns() as $column) { |
105 | 105 | if ($column->isText()) { |
106 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
106 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
107 | 107 | $sep = ', " ", '; |
108 | 108 | } |
109 | 109 | } |
110 | - foreach($tableMap->getRelations() as $relation) { |
|
111 | - if(preg_match('/I18n$/i', $relation->getName())) { |
|
110 | + foreach ($tableMap->getRelations() as $relation) { |
|
111 | + if (preg_match('/I18n$/i', $relation->getName())) { |
|
112 | 112 | $localeTableMap = $relation->getLocalTable(); |
113 | 113 | foreach ($localeTableMap->getColumns() as $column) { |
114 | 114 | if ($column->isText()) { |
115 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
115 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
116 | 116 | $sep = ', " ", '; |
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
121 | 121 | foreach (array_keys($extraColumns) as $extra) { |
122 | - if(!preg_match("/(COUNT|DISTINCT|SUM|MAX|MIN|GROUP)/i", $extra)) { |
|
123 | - $exp .= $sep . $extra; |
|
122 | + if (!preg_match("/(COUNT|DISTINCT|SUM|MAX|MIN|GROUP)/i", $extra)) { |
|
123 | + $exp .= $sep.$extra; |
|
124 | 124 | $sep = ', " ", '; |
125 | 125 | } |
126 | 126 | } |
127 | 127 | $exp .= ")"; |
128 | 128 | $text = preg_replace('/(\'|\")/', '', $value); |
129 | 129 | $text = preg_replace('/\ /', '%', $text); |
130 | - $query->where($exp . Criteria::LIKE . '"%' . $text . '%"'); |
|
130 | + $query->where($exp.Criteria::LIKE.'"%'.$text.'%"'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public static function extractPrimaryKeyColumnName(TableMap $tableMap) { |
138 | 138 | $modelPk = null; |
139 | - foreach($tableMap->getPrimaryKeys() as $pk) { |
|
139 | + foreach ($tableMap->getPrimaryKeys() as $pk) { |
|
140 | 140 | $modelPk = $pk; |
141 | 141 | break; |
142 | 142 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function getParams() |
19 | 19 | { |
20 | - return $this->params?: []; |
|
20 | + return $this->params ?: []; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return ParameterTrait |
50 | 50 | */ |
51 | 51 | public function dropParam($key) { |
52 | - if(array_key_exists($key, $this->params)) { |
|
52 | + if (array_key_exists($key, $this->params)) { |
|
53 | 53 | unset($this->params[$key]); |
54 | 54 | } |
55 | 55 | return $this; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return mixed|null |
61 | 61 | */ |
62 | 62 | public function getParam($key) { |
63 | - if(array_key_exists($key, $this->params)) { |
|
63 | + if (array_key_exists($key, $this->params)) { |
|
64 | 64 | return $this->params[$key]; |
65 | 65 | } |
66 | 66 | return null; |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | protected function hydrateBulkRequest() { |
97 | 97 | $class = new \ReflectionClass($this->getModelNamespace()); |
98 | 98 | $this->list = []; |
99 | - foreach($this->data as $item) { |
|
100 | - if(is_array($item)) { |
|
101 | - if(count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
99 | + foreach ($this->data as $item) { |
|
100 | + if (is_array($item)) { |
|
101 | + if (count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
102 | 102 | /** @var ActiveRecordInterface $model */ |
103 | 103 | $model = $class->newInstance(); |
104 | 104 | $this->hydrateModelFromRequest($model, $item); |
105 | 105 | $this->list[] = $model; |
106 | - } else { |
|
107 | - Logger::log(t('Max items per bulk insert raised'), LOG_WARNING, count($this->data) . t('items')); |
|
106 | + }else { |
|
107 | + Logger::log(t('Max items per bulk insert raised'), LOG_WARNING, count($this->data).t('items')); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | */ |
116 | 116 | protected function saveBulk() { |
117 | 117 | $tablemap = $this->getTableMap(); |
118 | - foreach($this->list as &$model) { |
|
118 | + foreach ($this->list as &$model) { |
|
119 | 119 | $con = Propel::getWriteConnection($tablemap::DATABASE_NAME); |
120 | 120 | try { |
121 | 121 | $model->save($con); |
122 | 122 | $con->commit(); |
123 | - } catch(\Exception $e) { |
|
123 | + }catch (\Exception $e) { |
|
124 | 124 | Logger::log($e->getMessage(), LOG_ERR, $model->toArray()); |
125 | 125 | $con->rollBack(); |
126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | protected function exportList() { |
134 | 134 | $list = []; |
135 | 135 | /** @var ActiveRecordInterface $item */ |
136 | - foreach($this->list as $item) { |
|
136 | + foreach ($this->list as $item) { |
|
137 | 137 | $list[] = $item->toArray(); |
138 | 138 | } |
139 | 139 | return $list; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param ModelCriteria $query |
146 | 146 | */ |
147 | - protected function joinTables(ModelCriteria &$query) |
|
147 | + protected function joinTables(ModelCriteria & $query) |
|
148 | 148 | { |
149 | 149 | //TODO for specific implementations |
150 | 150 | } |
@@ -157,18 +157,18 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected function findPk(ModelCriteria $query, $primaryKey) { |
159 | 159 | $pks = explode(Api::API_PK_SEPARATOR, urldecode($primaryKey)); |
160 | - if(count($pks) === 1 && !empty($pks[0])) { |
|
160 | + if (count($pks) === 1 && !empty($pks[0])) { |
|
161 | 161 | $query->filterByPrimaryKey($pks[0]); |
162 | - } else { |
|
162 | + }else { |
|
163 | 163 | $item = 0; |
164 | - foreach($this->getPkDbName() as $phpName) { |
|
164 | + foreach ($this->getPkDbName() as $phpName) { |
|
165 | 165 | try { |
166 | 166 | $query->filterBy($phpName, $pks[$item]); |
167 | 167 | $item++; |
168 | - if($item >= count($pks)) { |
|
168 | + if ($item >= count($pks)) { |
|
169 | 169 | break; |
170 | 170 | } |
171 | - } catch(\Exception $e) { |
|
171 | + }catch (\Exception $e) { |
|
172 | 172 | Logger::log($e->getMessage(), LOG_DEBUG); |
173 | 173 | } |
174 | 174 | } |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | try { |
199 | 199 | $query = $this->prepareQuery(); |
200 | 200 | $this->model = $this->findPk($query, $primaryKey); |
201 | - } catch (\Exception $e) { |
|
202 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
201 | + }catch (\Exception $e) { |
|
202 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | /** |
221 | 221 | * @param ModelCriteria $query |
222 | 222 | */ |
223 | - protected function checkReturnFields(ModelCriteria &$query) |
|
223 | + protected function checkReturnFields(ModelCriteria & $query) |
|
224 | 224 | { |
225 | 225 | $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD); |
226 | 226 | if (null !== $returnFields) { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if (count($pks) === 1) { |
82 | 82 | $pks = array_keys($pks); |
83 | 83 | return [ |
84 | - $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD |
|
84 | + $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD |
|
85 | 85 | ]; |
86 | 86 | } |
87 | 87 | if (count($pks) > 1) { |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | $principal = ''; |
90 | 90 | $sep = 'CONCAT('; |
91 | 91 | foreach ($pks as $pk) { |
92 | - $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName(); |
|
93 | - $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName(); |
|
94 | - $sep = ', "' . Api::API_PK_SEPARATOR . '", '; |
|
92 | + $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName(); |
|
93 | + $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName(); |
|
94 | + $sep = ', "'.Api::API_PK_SEPARATOR.'", '; |
|
95 | 95 | } |
96 | 96 | $principal .= ')'; |
97 | 97 | $apiPks[$principal] = Api::API_MODEL_KEY_FIELD; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | $pks = ''; |
119 | 119 | $sep = ''; |
120 | 120 | foreach ($tableMap->getPrimaryKeys() as $pk) { |
121 | - $pks .= $sep . $pk->getFullyQualifiedName(); |
|
121 | + $pks .= $sep.$pk->getFullyQualifiedName(); |
|
122 | 122 | $sep = ', "|", '; |
123 | 123 | } |
124 | - $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD; |
|
124 | + $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | if (null !== $column) { |
145 | 145 | $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD; |
146 | - } else { |
|
146 | + }else { |
|
147 | 147 | $this->addClassListName($tableMap); |
148 | 148 | } |
149 | 149 | } |
@@ -154,22 +154,22 @@ discard block |
||
154 | 154 | * @param $action |
155 | 155 | * @throws ApiException |
156 | 156 | */ |
157 | - private function addExtraColumns(ModelCriteria &$query, $action) |
|
157 | + private function addExtraColumns(ModelCriteria & $query, $action) |
|
158 | 158 | { |
159 | 159 | if (Api::API_ACTION_LIST === $action) { |
160 | 160 | $this->addDefaultListField(); |
161 | 161 | $this->addPkToList(); |
162 | 162 | } |
163 | 163 | if (!empty($this->extraColumns)) { |
164 | - if(Config::getParam('api.extrafields.compat', true)) { |
|
164 | + if (Config::getParam('api.extrafields.compat', true)) { |
|
165 | 165 | $fields = array_values($this->extraColumns); |
166 | - } else { |
|
166 | + }else { |
|
167 | 167 | $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD); |
168 | 168 | $fields = explode(',', $returnFields ?: ''); |
169 | 169 | $fields[] = self::API_MODEL_KEY_FIELD; |
170 | 170 | } |
171 | 171 | foreach ($this->extraColumns as $expression => $columnName) { |
172 | - if(empty($fields) || in_array($columnName, $fields)) { |
|
172 | + if (empty($fields) || in_array($columnName, $fields)) { |
|
173 | 173 | $query->withColumn($expression, $columnName); |
174 | 174 | } |
175 | 175 | } |
@@ -196,22 +196,22 @@ discard block |
||
196 | 196 | /** |
197 | 197 | * @param ModelCriteria $query |
198 | 198 | */ |
199 | - protected function checkI18n(ModelCriteria &$query) |
|
199 | + protected function checkI18n(ModelCriteria & $query) |
|
200 | 200 | { |
201 | 201 | $this->extractApiLang(); |
202 | 202 | $model = $this->getModelNamespace(); |
203 | - $modelI18n = $model . 'I18n'; |
|
203 | + $modelI18n = $model.'I18n'; |
|
204 | 204 | if (method_exists($query, 'useI18nQuery')) { |
205 | 205 | $query->useI18nQuery($this->lang); |
206 | 206 | $modelParts = explode('\\', $modelI18n); |
207 | - $i18nMapClass = str_replace(end($modelParts), 'Map\\' . end($modelParts), $modelI18n) . 'TableMap'; |
|
207 | + $i18nMapClass = str_replace(end($modelParts), 'Map\\'.end($modelParts), $modelI18n).'TableMap'; |
|
208 | 208 | /** @var TableMap $modelI18nTableMap */ |
209 | 209 | $modelI18nTableMap = $i18nMapClass::getTableMap(); |
210 | - foreach($modelI18nTableMap->getColumns() as $columnMap) { |
|
211 | - if(!$columnMap->isPrimaryKey()) { |
|
210 | + foreach ($modelI18nTableMap->getColumns() as $columnMap) { |
|
211 | + if (!$columnMap->isPrimaryKey()) { |
|
212 | 212 | $query->withColumn($columnMap->getFullyQualifiedName(), ApiHelper::getColumnMapName($columnMap)); |
213 | - } elseif(!$columnMap->isForeignKey()) { |
|
214 | - $query->withColumn('IFNULL(' . $columnMap->getFullyQualifiedName() . ', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap)); |
|
213 | + } elseif (!$columnMap->isForeignKey()) { |
|
214 | + $query->withColumn('IFNULL('.$columnMap->getFullyQualifiedName().', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap)); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | } |
@@ -225,22 +225,22 @@ discard block |
||
225 | 225 | $model->fromArray($data, ApiHelper::getFieldTypes()); |
226 | 226 | $tableMap = $this->getTableMap(); |
227 | 227 | try { |
228 | - if($tableMap->hasRelation($tableMap->getPhpName() . 'I18n')) |
|
228 | + if ($tableMap->hasRelation($tableMap->getPhpName().'I18n')) |
|
229 | 229 | { |
230 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
230 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
231 | 231 | $i18NTableMap = $relateI18n->getLocalTable(); |
232 | 232 | $model->setLocale(array_key_exists('Locale', $data) ? $data['Locale'] : (array_key_exists('locale', $data) ? $data['locale'] : Request::header(Api::HEADER_API_LANG, 'es_ES'))); |
233 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
234 | - $method = 'set' . $columnMap->getPhpName(); |
|
233 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
234 | + $method = 'set'.$columnMap->getPhpName(); |
|
235 | 235 | $dtoColumnName = ApiHelper::getColumnMapName($columnMap); |
236 | - if(array_key_exists($dtoColumnName, $data) |
|
236 | + if (array_key_exists($dtoColumnName, $data) |
|
237 | 237 | && method_exists($model, $method) |
238 | 238 | && !($columnMap->isPrimaryKey() && $columnMap->isForeignKey())) { |
239 | 239 | $model->$method($data[$dtoColumnName]); |
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
243 | - } catch(Exception $e) { |
|
243 | + }catch (Exception $e) { |
|
244 | 244 | Logger::log($e->getMessage(), LOG_DEBUG); |
245 | 245 | } |
246 | 246 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | GeneratorHelper::checkCustomNamespaceApi($apiClass); |
64 | 64 | $this->gen->createStructureModule($module, false, $type, $apiClass); |
65 | 65 | Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, t("Módulo %s generado correctamente"))); |
66 | - Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true)); |
|
66 | + Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true)); |
|
67 | 67 | } catch (Exception $e) { |
68 | 68 | Logger::log($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]"); |
69 | 69 | Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage())); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function generateModule() |
35 | 35 | { |
36 | - Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri()); |
|
36 | + Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri()); |
|
37 | 37 | /* @var $form ConfigForm */ |
38 | 38 | $form = new ModuleForm(); |
39 | 39 | $form->build(); |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | $this->gen->createStructureModule($module, false, $type, $apiClass); |
65 | 65 | Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, t("Módulo %s generado correctamente"))); |
66 | 66 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true)); |
67 | - } catch (Exception $e) { |
|
68 | - Logger::log($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]"); |
|
67 | + }catch (Exception $e) { |
|
68 | + Logger::log($e->getMessage()." [".$e->getFile().":".$e->getLine()."]"); |
|
69 | 69 | Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage())); |
70 | 70 | } |
71 | 71 | } |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | foreach ($compiledFiles as $file) { |
24 | 24 | echo "\t\t<script type='text/javascript' src='{$file}'></script>\n"; |
25 | 25 | } |
26 | - } else { |
|
27 | - echo "\t\t<script type='text/javascript' src='" . $baseUrl . "/js/" . $hash . ".js'" . |
|
26 | + }else { |
|
27 | + echo "\t\t<script type='text/javascript' src='".$baseUrl."/js/".$hash.".js'". |
|
28 | 28 | "></script>\n"; |
29 | 29 | } |
30 | 30 | } |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | */ |
41 | 41 | protected function putDebugJs($pathParts, $base, $file, $hash, array &$compiledFiles) |
42 | 42 | { |
43 | - $filePath = $hash . "_" . $pathParts[count($pathParts) - 1]; |
|
44 | - $compiledFiles[] = "/js/" . $filePath; |
|
43 | + $filePath = $hash."_".$pathParts[count($pathParts) - 1]; |
|
44 | + $compiledFiles[] = "/js/".$filePath; |
|
45 | 45 | $data = ""; |
46 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file)) { |
|
46 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file)) { |
|
47 | 47 | $data = file_get_contents($file); |
48 | - AssetsHelper::storeContents($base . $filePath, $data); |
|
48 | + AssetsHelper::storeContents($base.$filePath, $data); |
|
49 | 49 | } |
50 | 50 | return $data; |
51 | 51 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | */ |
62 | 62 | protected function compileJs(array $files, $basePath, $hash, array &$compiledFiles) |
63 | 63 | { |
64 | - $base = $basePath . "js" . DIRECTORY_SEPARATOR; |
|
64 | + $base = $basePath."js".DIRECTORY_SEPARATOR; |
|
65 | 65 | $debug = Config::getParam('debug'); |
66 | - if ($debug || !file_exists($base . $hash . ".js")) { |
|
66 | + if ($debug || !file_exists($base.$hash.".js")) { |
|
67 | 67 | $data = ''; |
68 | 68 | if (0 < count($files)) { |
69 | 69 | $minifier = new JS(); |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | if (file_exists($file)) { |
73 | 73 | if ($debug) { |
74 | 74 | $data = $this->putDebugJs($pathParts, $base, $file, $hash, $compiledFiles); |
75 | - } elseif (!file_exists($base . $hash . ".js")) { |
|
75 | + } elseif (!file_exists($base.$hash.".js")) { |
|
76 | 76 | $minifier->add($file); |
77 | 77 | //$data = $this->putProductionJs($base, $file, $data); |
78 | 78 | } |
79 | 79 | } |
80 | 80 | } |
81 | - if($debug) { |
|
82 | - AssetsHelper::storeContents($base . $hash . ".js", $data); |
|
83 | - } else { |
|
81 | + if ($debug) { |
|
82 | + AssetsHelper::storeContents($base.$hash.".js", $data); |
|
83 | + }else { |
|
84 | 84 | $this->dumpJs($hash, $base, $minifier); |
85 | 85 | } |
86 | 86 | unset($minifier); |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | ini_set('memory_limit', -1); |
102 | 102 | GeneratorHelper::createDir($base); |
103 | 103 | if (Config::getParam('assets.obfuscate', false)) { |
104 | - $minifier->gzip($base . $hash . ".js"); |
|
105 | - } else { |
|
106 | - $minifier->minify($base . $hash . ".js"); |
|
104 | + $minifier->gzip($base.$hash.".js"); |
|
105 | + }else { |
|
106 | + $minifier->minify($base.$hash.".js"); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | } |