@@ -52,8 +52,9 @@ |
||
| 52 | 52 | */ |
| 53 | 53 | public function setValue($value) |
| 54 | 54 | { |
| 55 | - if ($value === 'true' || $value === true) |
|
| 56 | - $this->getForm()->submittedButton=$this->getName(); |
|
| 55 | + if ($value === 'true' || $value === true) { |
|
| 56 | + $this->getForm()->submittedButton=$this->getName(); |
|
| 57 | + } |
|
| 57 | 58 | return $this; |
| 58 | 59 | } |
| 59 | 60 | |
@@ -66,10 +66,12 @@ discard block |
||
| 66 | 66 | if ($searchData !== '') { |
| 67 | 67 | $dateFrom = Arr::get($searchData, 'from'); |
| 68 | 68 | $dateTo = Arr::get($searchData, 'to'); |
| 69 | - if ($dateFrom) |
|
| 70 | - $query->where($this->getDataKey(), '>=', $dateFrom); |
|
| 71 | - if ($dateTo) |
|
| 72 | - $query->where($this->getDataKey(), '<=', $dateTo); |
|
| 69 | + if ($dateFrom) { |
|
| 70 | + $query->where($this->getDataKey(), '>=', $dateFrom); |
|
| 71 | + } |
|
| 72 | + if ($dateTo) { |
|
| 73 | + $query->where($this->getDataKey(), '<=', $dateTo); |
|
| 74 | + } |
|
| 73 | 75 | } |
| 74 | 76 | } |
| 75 | 77 | |
@@ -87,8 +89,9 @@ discard block |
||
| 87 | 89 | public function getValue() |
| 88 | 90 | { |
| 89 | 91 | $value = parent::getValue(); |
| 90 | - if (is_array($value)) |
|
| 91 | - return $value; |
|
| 92 | + if (is_array($value)) { |
|
| 93 | + return $value; |
|
| 94 | + } |
|
| 92 | 95 | return ['from' => '', 'to' => '']; |
| 93 | 96 | } |
| 94 | 97 | |
@@ -21,8 +21,8 @@ |
||
| 21 | 21 | public $dataMapKey = 'users'; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * @inheritdoc |
|
| 25 | - */ |
|
| 24 | + * @inheritdoc |
|
| 25 | + */ |
|
| 26 | 26 | public function getComponentDetails() |
| 27 | 27 | { |
| 28 | 28 | return [ |
@@ -14,21 +14,21 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | class ImageCompare extends ImageMultiple |
| 16 | 16 | { |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * @inheritdoc |
| 19 | 19 | */ |
| 20 | - public $ddsDataType = 'json'; |
|
| 20 | + public $ddsDataType = 'json'; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 22 | + /** |
|
| 23 | 23 | * @inheritdoc |
| 24 | 24 | */ |
| 25 | 25 | public function registerScripts($view) |
| 26 | 26 | { |
| 27 | - $view->registerAssetBundle(\neon\cms\assets\CmsFormAsset::class); |
|
| 27 | + $view->registerAssetBundle(\neon\cms\assets\CmsFormAsset::class); |
|
| 28 | 28 | $view->registerAssetBundle(\neon\firefly\assets\BrowserAsset::class); |
| 29 | - } |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * @inheritdoc |
| 33 | 33 | */ |
| 34 | 34 | public function getFilterField() |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | return ['class' => 'neon\\core\\form\\fields\\Text']; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - /** |
|
| 39 | + /** |
|
| 40 | 40 | * @inheritdoc |
| 41 | 41 | */ |
| 42 | 42 | public function getComponentDetails() |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | return [ |
| 45 | 45 | 'icon' => 'fa fa-image', 'group' => 'Media', 'order' => 612, 'label' => 'Image Compare' |
| 46 | 46 | ]; |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function getValueDisplay($context='') |
|
| 49 | + public function getValueDisplay($context='') |
|
| 50 | 50 | { |
| 51 | 51 | $json = $this->getValue(); |
| 52 | 52 | if (empty($json)) |
@@ -311,8 +311,9 @@ discard block |
||
| 311 | 311 | return $scope['key']; |
| 312 | 312 | } |
| 313 | 313 | // No url request scope defined check if a default is set |
| 314 | - if ($this->defaultScope !== null) |
|
| 315 | - return $this->defaultScope; |
|
| 314 | + if ($this->defaultScope !== null) { |
|
| 315 | + return $this->defaultScope; |
|
| 316 | + } |
|
| 316 | 317 | |
| 317 | 318 | // No default scope so return the first in the list as the default |
| 318 | 319 | $defaultScope = reset($this->_scopes); |
@@ -441,8 +442,9 @@ discard block |
||
| 441 | 442 | foreach($this->getColumns() as $key => $column) { |
| 442 | 443 | if ($column->getFilter() && $column->getFilterField() !== false) { |
| 443 | 444 | $field = $column->getFilterField(); |
| 444 | - if (is_object($field)) |
|
| 445 | - $field = $field->toArray(); |
|
| 445 | + if (is_object($field)) { |
|
| 446 | + $field = $field->toArray(); |
|
| 447 | + } |
|
| 446 | 448 | $field['name'] = $key; |
| 447 | 449 | $field['dataKey'] = $column->getDbField(); |
| 448 | 450 | $this->_filterForm->add($field); |
@@ -643,8 +645,9 @@ discard block |
||
| 643 | 645 | $formsDefinitionCache[$cacheKey] = $formDefinition; |
| 644 | 646 | } |
| 645 | 647 | $form = new \neon\core\form\Form($formsDefinitionCache[$cacheKey]); |
| 646 | - if ($member === null) |
|
| 647 | - $member = $key; |
|
| 648 | + if ($member === null) { |
|
| 649 | + $member = $key; |
|
| 650 | + } |
|
| 648 | 651 | return $this->addColumn($key, [ |
| 649 | 652 | 'title' => $form->getField($member)->getLabel(), |
| 650 | 653 | 'class' => 'neon\core\grid\column\Column', |
@@ -706,8 +709,9 @@ discard block |
||
| 706 | 709 | */ |
| 707 | 710 | public function removeColumn($key) |
| 708 | 711 | { |
| 709 | - if ($this->columnExists($key)) |
|
| 710 | - unset($this->_columns[$key]); |
|
| 712 | + if ($this->columnExists($key)) { |
|
| 713 | + unset($this->_columns[$key]); |
|
| 714 | + } |
|
| 711 | 715 | } |
| 712 | 716 | |
| 713 | 717 | /** |
@@ -754,8 +758,9 @@ discard block |
||
| 754 | 758 | */ |
| 755 | 759 | public function refreshDataProvider() |
| 756 | 760 | { |
| 757 | - if ($this->_dataProvider) |
|
| 758 | - $this->_dataProvider = clone $this->getDataProvider(); |
|
| 761 | + if ($this->_dataProvider) { |
|
| 762 | + $this->_dataProvider = clone $this->getDataProvider(); |
|
| 763 | + } |
|
| 759 | 764 | } |
| 760 | 765 | |
| 761 | 766 | /** |
@@ -780,8 +785,9 @@ discard block |
||
| 780 | 785 | */ |
| 781 | 786 | public function gridBoot() |
| 782 | 787 | { |
| 783 | - if (! $this->hasData()) |
|
| 784 | - $this->_gridData = Arr::get($_REQUEST, $this->id, null); |
|
| 788 | + if (! $this->hasData()) { |
|
| 789 | + $this->_gridData = Arr::get($_REQUEST, $this->id, null); |
|
| 790 | + } |
|
| 785 | 791 | // load the active scope |
| 786 | 792 | $this->_scope = Arr::get($this->_gridData, "scope", []); |
| 787 | 793 | // load request data into the form |
@@ -818,8 +824,9 @@ discard block |
||
| 818 | 824 | public function exportCsv($page=0, $pageSize=1000, $asRows=false) |
| 819 | 825 | { |
| 820 | 826 | // check we're allowed to do this |
| 821 | - if (!$this->canExportCsv) |
|
| 822 | - return null; |
|
| 827 | + if (!$this->canExportCsv) { |
|
| 828 | + return null; |
|
| 829 | + } |
|
| 823 | 830 | |
| 824 | 831 | $this->gridBoot(); |
| 825 | 832 | // Get header column names |
@@ -841,8 +848,9 @@ discard block |
||
| 841 | 848 | $pagination->page=$page; |
| 842 | 849 | $pagination->pageSize = min(1000,$pageSize); |
| 843 | 850 | $models = $dataProvider->getModels(); |
| 844 | - if (empty($models)) |
|
| 845 | - return null; |
|
| 851 | + if (empty($models)) { |
|
| 852 | + return null; |
|
| 853 | + } |
|
| 846 | 854 | |
| 847 | 855 | $rows = []; |
| 848 | 856 | foreach($models as $index => $row) { |
@@ -858,8 +866,9 @@ discard block |
||
| 858 | 866 | $dataProvider->models = null; |
| 859 | 867 | |
| 860 | 868 | // Add headers columns as the first row if we are on the first page |
| 861 | - if ($page==0) |
|
| 862 | - array_unshift($rows, implode(',', $headerCols)); |
|
| 869 | + if ($page==0) { |
|
| 870 | + array_unshift($rows, implode(',', $headerCols)); |
|
| 871 | + } |
|
| 863 | 872 | |
| 864 | 873 | return $asRows ? $rows : implode("\n", $rows); |
| 865 | 874 | } |
@@ -935,8 +944,9 @@ discard block |
||
| 935 | 944 | { |
| 936 | 945 | foreach ($this->getScopes() as $key => $scope) { |
| 937 | 946 | // counts across whole tables are very very expensive. Don't count more than once |
| 938 | - if (isset($this->_scopeCounts[$key])) |
|
| 939 | - continue; |
|
| 947 | + if (isset($this->_scopeCounts[$key])) { |
|
| 948 | + continue; |
|
| 949 | + } |
|
| 940 | 950 | $dp = clone $this->getDataProvider(); |
| 941 | 951 | // call the scope function defined by `'scope'.$key` functions in child classes |
| 942 | 952 | $this->callScope($scope, $dp->getQueryBuilder()); |
@@ -964,8 +974,9 @@ discard block |
||
| 964 | 974 | public function processSearch() |
| 965 | 975 | { |
| 966 | 976 | $data = $this->getGridData(); |
| 967 | - if (!isset($data['filter'])) |
|
| 968 | - return; |
|
| 977 | + if (!isset($data['filter'])) { |
|
| 978 | + return; |
|
| 979 | + } |
|
| 969 | 980 | foreach ($this->getColumns() as $key => $column) { |
| 970 | 981 | // check there is a form filter field |
| 971 | 982 | // check that the filter field has request data |
@@ -1049,8 +1060,9 @@ discard block |
||
| 1049 | 1060 | */ |
| 1050 | 1061 | public function getColumn($columnKey) |
| 1051 | 1062 | { |
| 1052 | - if (!isset($this->_columns[$columnKey])) |
|
| 1053 | - throw new \Exception("No column with key '$columnKey' exists in the grid"); |
|
| 1063 | + if (!isset($this->_columns[$columnKey])) { |
|
| 1064 | + throw new \Exception("No column with key '$columnKey' exists in the grid"); |
|
| 1065 | + } |
|
| 1054 | 1066 | return $this->_columns[$columnKey]; |
| 1055 | 1067 | } |
| 1056 | 1068 | |
@@ -1141,8 +1153,9 @@ discard block |
||
| 1141 | 1153 | { |
| 1142 | 1154 | $columns = []; |
| 1143 | 1155 | foreach($this->getColumns() as $key => $column) { |
| 1144 | - if ($column->visible) |
|
| 1145 | - $columns[$key] = $column; |
|
| 1156 | + if ($column->visible) { |
|
| 1157 | + $columns[$key] = $column; |
|
| 1158 | + } |
|
| 1146 | 1159 | } |
| 1147 | 1160 | return $columns; |
| 1148 | 1161 | } |
@@ -1187,8 +1200,9 @@ discard block |
||
| 1187 | 1200 | */ |
| 1188 | 1201 | public function getIndexColumn() |
| 1189 | 1202 | { |
| 1190 | - if (!isset($this->_columns[$this->_indexedByColumn])) |
|
| 1191 | - throw new \Exception("No index column exists with key '$this->_indexedByColumn'."); |
|
| 1203 | + if (!isset($this->_columns[$this->_indexedByColumn])) { |
|
| 1204 | + throw new \Exception("No index column exists with key '$this->_indexedByColumn'."); |
|
| 1205 | + } |
|
| 1192 | 1206 | return $this->_columns[$this->_indexedByColumn]; |
| 1193 | 1207 | } |
| 1194 | 1208 | |
@@ -1250,8 +1264,9 @@ discard block |
||
| 1250 | 1264 | $plain = html_entity_decode( |
| 1251 | 1265 | str_replace(["\n", '"'], ['', '\''], strip_tags($content)), |
| 1252 | 1266 | ENT_HTML401 | ENT_QUOTES | ENT_HTML5); |
| 1253 | - if ($plain === $this->emptyCellDisplay) |
|
| 1254 | - $plain = ''; |
|
| 1267 | + if ($plain === $this->emptyCellDisplay) { |
|
| 1268 | + $plain = ''; |
|
| 1269 | + } |
|
| 1255 | 1270 | return '"'.$plain.'"'; |
| 1256 | 1271 | } |
| 1257 | 1272 | } |
@@ -45,8 +45,9 @@ discard block |
||
| 45 | 45 | public function __clone() |
| 46 | 46 | { |
| 47 | 47 | parent::__clone(); |
| 48 | - if ($this->_queryBuilder) |
|
| 49 | - $this->_queryBuilder = clone $this->_queryBuilder; |
|
| 48 | + if ($this->_queryBuilder) { |
|
| 49 | + $this->_queryBuilder = clone $this->_queryBuilder; |
|
| 50 | + } |
|
| 50 | 51 | } |
| 51 | 52 | |
| 52 | 53 | /** |
@@ -67,8 +68,9 @@ discard block |
||
| 67 | 68 | { |
| 68 | 69 | // prepare pagination |
| 69 | 70 | $pagination = $this->getPagination(); |
| 70 | - if ($pagination === false) |
|
| 71 | - return []; |
|
| 71 | + if ($pagination === false) { |
|
| 72 | + return []; |
|
| 73 | + } |
|
| 72 | 74 | // depending on how this grid was set up, this call may or may not have been made. |
| 73 | 75 | // The results are cached so call it here to be safe. |
| 74 | 76 | $totalCount = $this->getTotalCount(); |
@@ -108,8 +108,9 @@ discard block |
||
| 108 | 108 | // set null result information about the request |
| 109 | 109 | $newData[$k] = ['start' => $r['limit']['start'], 'length' => 0, 'total' => $r['total'], 'rows' => []]; |
| 110 | 110 | $sql[] = $r['sql']; |
| 111 | - if ($r['totalSql']) |
|
| 112 | - $sql[] = $r['totalSql']; |
|
| 111 | + if ($r['totalSql']) { |
|
| 112 | + $sql[] = $r['totalSql']; |
|
| 113 | + } |
|
| 113 | 114 | $resultKey2RequestKey[$r['resultKey']] = $r['requestKey']; |
| 114 | 115 | } |
| 115 | 116 | } |
@@ -170,8 +171,9 @@ discard block |
||
| 170 | 171 | */ |
| 171 | 172 | public function runSingleObjectRequest($classType, array $filters = [], array $order = [], array $limit = [], $includeDeleted = false) |
| 172 | 173 | { |
| 173 | - if (empty($classType)) |
|
| 174 | - throw new \InvalidArgumentException('ClassType must be specified'); |
|
| 174 | + if (empty($classType)) { |
|
| 175 | + throw new \InvalidArgumentException('ClassType must be specified'); |
|
| 176 | + } |
|
| 175 | 177 | |
| 176 | 178 | // make sure that any currently queued requests from elsewhere are saved off the queue |
| 177 | 179 | $currentRequests = $this->popRequests(); |
@@ -254,16 +256,18 @@ discard block |
||
| 254 | 256 | public function listObjects($classType, &$total = null, $includeDeleted = false, $inFull = true, $start = 0, $length = 100, $order = null) |
| 255 | 257 | { |
| 256 | 258 | $classType = $this->canonicaliseRef($classType); |
| 257 | - if (empty($order)) |
|
| 258 | - $order = ['_created' => 'DESC']; |
|
| 259 | + if (empty($order)) { |
|
| 260 | + $order = ['_created' => 'DESC']; |
|
| 261 | + } |
|
| 259 | 262 | $order = $this->canonicaliseOrder($order); |
| 260 | 263 | |
| 261 | 264 | // get the total first |
| 262 | 265 | $class = null; |
| 263 | 266 | $this->findClass($classType, $class, true); |
| 264 | 267 | $total = $class->count_total; |
| 265 | - if (!$includeDeleted) |
|
| 266 | - $total -= $class->count_deleted; |
|
| 268 | + if (!$includeDeleted) { |
|
| 269 | + $total -= $class->count_deleted; |
|
| 270 | + } |
|
| 267 | 271 | |
| 268 | 272 | // now get the objects |
| 269 | 273 | $query = (new \neon\core\db\Query) |
@@ -273,8 +277,9 @@ discard block |
||
| 273 | 277 | ->offset($start) |
| 274 | 278 | ->limit($length); |
| 275 | 279 | |
| 276 | - if (!$includeDeleted) |
|
| 277 | - $query->andWhere('[[o]].[[_deleted]] = 0'); |
|
| 280 | + if (!$includeDeleted) { |
|
| 281 | + $query->andWhere('[[o]].[[_deleted]] = 0'); |
|
| 282 | + } |
|
| 278 | 283 | if ($inFull) { |
| 279 | 284 | $tableName = $this->getTableFromClassType($classType); |
| 280 | 285 | $query->innerJoin('{{' . $tableName . '}} t', '[[o]].[[_uuid]]=[[t]].[[_uuid]]'); |
@@ -289,8 +294,9 @@ discard block |
||
| 289 | 294 | $orderBits[] = "[[t]].$k $d"; |
| 290 | 295 | } |
| 291 | 296 | } |
| 292 | - if ($orderBits) |
|
| 293 | - $orderClause = implode(', ', $orderBits); |
|
| 297 | + if ($orderBits) { |
|
| 298 | + $orderClause = implode(', ', $orderBits); |
|
| 299 | + } |
|
| 294 | 300 | $query->orderBy($orderClause); |
| 295 | 301 | } |
| 296 | 302 | |
@@ -307,8 +313,9 @@ discard block |
||
| 307 | 313 | $class = null; |
| 308 | 314 | $classType = $this->canonicaliseRef($classType); |
| 309 | 315 | $this->findClass($classType, $class, true); |
| 310 | - if ($class->hasChangeLog()) |
|
| 311 | - $newValues = $data; |
|
| 316 | + if ($class->hasChangeLog()) { |
|
| 317 | + $newValues = $data; |
|
| 318 | + } |
|
| 312 | 319 | $table = $this->getTableFromClassType($classType); |
| 313 | 320 | |
| 314 | 321 | // create the new object |
@@ -319,8 +326,9 @@ discard block |
||
| 319 | 326 | $object->_class_type = $classType; |
| 320 | 327 | $object->_created = $now; |
| 321 | 328 | $object->_updated = $now; |
| 322 | - if (!$object->save()) |
|
| 323 | - throw new \RuntimeException("Couldn't create object: " . print_r($object->errors, true)); |
|
| 329 | + if (!$object->save()) { |
|
| 330 | + throw new \RuntimeException("Couldn't create object: " . print_r($object->errors, true)); |
|
| 331 | + } |
|
| 324 | 332 | |
| 325 | 333 | // increment the class's object count |
| 326 | 334 | $class->count_total += 1; |
@@ -344,10 +352,11 @@ discard block |
||
| 344 | 352 | } |
| 345 | 353 | } |
| 346 | 354 | |
| 347 | - if (count($fields)) |
|
| 348 | - $query = "INSERT INTO `$table` (`_uuid`, " . implode(', ', $fields) . ") VALUES ('{$object->_uuid}', " . implode(', ', $inserts) . ")"; |
|
| 349 | - else |
|
| 350 | - $query = "INSERT INTO `$table` (`_uuid`) VALUES ('{$object->_uuid}')"; |
|
| 355 | + if (count($fields)) { |
|
| 356 | + $query = "INSERT INTO `$table` (`_uuid`, " . implode(', ', $fields) . ") VALUES ('{$object->_uuid}', " . implode(', ', $inserts) . ")"; |
|
| 357 | + } else { |
|
| 358 | + $query = "INSERT INTO `$table` (`_uuid`) VALUES ('{$object->_uuid}')"; |
|
| 359 | + } |
|
| 351 | 360 | $command = neon()->db->createCommand($query); |
| 352 | 361 | $command->bindValues($values); |
| 353 | 362 | $command->execute(); |
@@ -355,8 +364,9 @@ discard block |
||
| 355 | 364 | // if there are any links then add these to the link table |
| 356 | 365 | $this->setMemberLinks($object->_uuid, $links); |
| 357 | 366 | |
| 358 | - if ($class->hasChangeLog()) |
|
| 359 | - $changeLogUuid = $this->createChangeLogEntry($class, 'ADD', $object->_uuid, [], $newValues); |
|
| 367 | + if ($class->hasChangeLog()) { |
|
| 368 | + $changeLogUuid = $this->createChangeLogEntry($class, 'ADD', $object->_uuid, [], $newValues); |
|
| 369 | + } |
|
| 360 | 370 | } catch (\Exception $e) { |
| 361 | 371 | // execution failed so clean up the object |
| 362 | 372 | $object->delete(); |
@@ -400,8 +410,9 @@ discard block |
||
| 400 | 410 | $objectsLinks = []; |
| 401 | 411 | $now = date('Y-m-d H:i:s'); |
| 402 | 412 | foreach ($chunkData as $row) { |
| 403 | - if ($hasChangeLog) |
|
| 404 | - $newValues = $row; |
|
| 413 | + if ($hasChangeLog) { |
|
| 414 | + $newValues = $row; |
|
| 415 | + } |
|
| 405 | 416 | // ddt table value - format row data and append the uuid |
| 406 | 417 | $this->convertFromPHPToDB($classType, $row, $links); |
| 407 | 418 | $uuid = (!empty($row['_uuid']) && $this->isUUID($row['_uuid'])) ? $row['_uuid'] : $this->generateUUID(); |
@@ -411,8 +422,9 @@ discard block |
||
| 411 | 422 | // object table row value |
| 412 | 423 | $objectDbRows[] = [$row['_uuid'], $classType, $now, $now]; |
| 413 | 424 | $objectsLinks[$row['_uuid']] = $links; |
| 414 | - if ($hasChangeLog) |
|
| 415 | - $this->createChangeLogEntry($class, 'ADD', $uuid, [], $newValues); |
|
| 425 | + if ($hasChangeLog) { |
|
| 426 | + $this->createChangeLogEntry($class, 'ADD', $uuid, [], $newValues); |
|
| 427 | + } |
|
| 416 | 428 | } |
| 417 | 429 | neon()->db->createCommand()->batchInsert(DdsObject::tableName(), ['_uuid', '_class_type', '_created', '_updated'], $objectDbRows)->execute(); |
| 418 | 430 | neon()->db->createCommand()->batchInsert($table, $columns, $rows)->execute(); |
@@ -446,20 +458,23 @@ discard block |
||
| 446 | 458 | public function editObject($uuid, array $changes, &$changeLogUuid = null) |
| 447 | 459 | { |
| 448 | 460 | // check there are some changes to make |
| 449 | - if (count($changes) == 0) |
|
| 450 | - return false; |
|
| 461 | + if (count($changes) == 0) { |
|
| 462 | + return false; |
|
| 463 | + } |
|
| 451 | 464 | |
| 452 | 465 | // check that the object exists and find its class type |
| 453 | - if (!$this->getObjectFromId($uuid, $object)) |
|
| 454 | - throw new \InvalidArgumentException("Couldn't edit object with id $uuid as not found"); |
|
| 466 | + if (!$this->getObjectFromId($uuid, $object)) { |
|
| 467 | + throw new \InvalidArgumentException("Couldn't edit object with id $uuid as not found"); |
|
| 468 | + } |
|
| 455 | 469 | |
| 456 | 470 | // see if we need to store the change log |
| 457 | 471 | $class = null; |
| 458 | 472 | $this->findClass($object['_class_type'], $class); |
| 459 | 473 | |
| 460 | 474 | $object->_updated = date('Y-m-d H:i:s'); |
| 461 | - if (!$object->save()) |
|
| 462 | - return $object->errors; |
|
| 475 | + if (!$object->save()) { |
|
| 476 | + return $object->errors; |
|
| 477 | + } |
|
| 463 | 478 | |
| 464 | 479 | // now update any member changes |
| 465 | 480 | try { |
@@ -488,8 +503,9 @@ discard block |
||
| 488 | 503 | } |
| 489 | 504 | } |
| 490 | 505 | } |
| 491 | - if (count($updates) == 0) |
|
| 492 | - return false; |
|
| 506 | + if (count($updates) == 0) { |
|
| 507 | + return false; |
|
| 508 | + } |
|
| 493 | 509 | |
| 494 | 510 | $query = "UPDATE `$table` SET " . implode(', ', $updates) . " WHERE `_uuid`='$uuid' LIMIT 1"; |
| 495 | 511 | neon()->db->createCommand($query)->bindValues($values)->execute(); |
@@ -498,8 +514,9 @@ discard block |
||
| 498 | 514 | $this->setMemberLinks($object->_uuid, $links); |
| 499 | 515 | |
| 500 | 516 | // finally note the changes in the change log |
| 501 | - if ($class && $class->hasChangeLog()) |
|
| 502 | - $changeLogUuid = $this->createChangeLogEntry($class, 'EDIT', $uuid, $originalValues, $newValues); |
|
| 517 | + if ($class && $class->hasChangeLog()) { |
|
| 518 | + $changeLogUuid = $this->createChangeLogEntry($class, 'EDIT', $uuid, $originalValues, $newValues); |
|
| 519 | + } |
|
| 503 | 520 | } catch (\yii\db\exception $e) { |
| 504 | 521 | $this->clearCaches(); |
| 505 | 522 | return ['error' => $e->getMessage()]; |
@@ -521,12 +538,14 @@ discard block |
||
| 521 | 538 | */ |
| 522 | 539 | public function editObjects($classType, array $uuids, array $changes) |
| 523 | 540 | { |
| 524 | - if (count($uuids) == 0 || count($changes) == 0) |
|
| 525 | - return false; |
|
| 541 | + if (count($uuids) == 0 || count($changes) == 0) { |
|
| 542 | + return false; |
|
| 543 | + } |
|
| 526 | 544 | try { |
| 527 | 545 | $uuids = $this->checkUuidsAgainstClassType($uuids, $classType); |
| 528 | - if (count($uuids) == 0) |
|
| 529 | - return false; |
|
| 546 | + if (count($uuids) == 0) { |
|
| 547 | + return false; |
|
| 548 | + } |
|
| 530 | 549 | $table = $this->getTableFromClassType($classType); |
| 531 | 550 | $memberStorage = $this->getMemberStorage($classType); |
| 532 | 551 | if (count($memberStorage) == 0) { |
@@ -537,8 +556,9 @@ discard block |
||
| 537 | 556 | $class = null; |
| 538 | 557 | $this->findClass($classType, $class); |
| 539 | 558 | if ($class && $class->hasChangeLog()) { |
| 540 | - foreach ($uuids as $uuid) |
|
| 541 | - $beforeValues[$uuid] = array_intersect_key($this->getObject($uuid), $changes); |
|
| 559 | + foreach ($uuids as $uuid) { |
|
| 560 | + $beforeValues[$uuid] = array_intersect_key($this->getObject($uuid), $changes); |
|
| 561 | + } |
|
| 542 | 562 | $newValues = $changes; |
| 543 | 563 | } |
| 544 | 564 | |
@@ -560,8 +580,9 @@ discard block |
||
| 560 | 580 | } |
| 561 | 581 | } |
| 562 | 582 | } |
| 563 | - if (count($updates) == 0) |
|
| 564 | - return false; |
|
| 583 | + if (count($updates) == 0) { |
|
| 584 | + return false; |
|
| 585 | + } |
|
| 565 | 586 | |
| 566 | 587 | // sort out the uuid clause for both the update on the table and in the object table |
| 567 | 588 | $uuidClause = []; |
@@ -589,8 +610,9 @@ discard block |
||
| 589 | 610 | |
| 590 | 611 | // and save entries into a change log |
| 591 | 612 | if ($class && $class->hasChangeLog()) { |
| 592 | - foreach ($beforeValues as $uuid => $before) |
|
| 593 | - $this->createChangeLogEntry($class, 'EDIT', $uuid, $before, $newValues); |
|
| 613 | + foreach ($beforeValues as $uuid => $before) { |
|
| 614 | + $this->createChangeLogEntry($class, 'EDIT', $uuid, $before, $newValues); |
|
| 615 | + } |
|
| 594 | 616 | } |
| 595 | 617 | } catch (\yii\db\exception $e) { |
| 596 | 618 | $this->clearCaches(); |
@@ -610,8 +632,9 @@ discard block |
||
| 610 | 632 | if ($this->getObjectFromId($uuid, $object) && $object->_deleted == 0) { |
| 611 | 633 | $object->_deleted = 1; |
| 612 | 634 | $object->_updated = date('Y-m-d H:i:s'); |
| 613 | - if (!$object->save()) |
|
| 614 | - throw new \RuntimeException("Couldn't delete the object: " . print_r($object->errors, true)); |
|
| 635 | + if (!$object->save()) { |
|
| 636 | + throw new \RuntimeException("Couldn't delete the object: " . print_r($object->errors, true)); |
|
| 637 | + } |
|
| 615 | 638 | // and update the class object deleted count |
| 616 | 639 | $class = null; |
| 617 | 640 | $this->findClass($object['_class_type'], $class); |
@@ -619,8 +642,9 @@ discard block |
||
| 619 | 642 | $class->save(); |
| 620 | 643 | |
| 621 | 644 | // see if we need to store the change log |
| 622 | - if ($class && $class->hasChangeLog()) |
|
| 623 | - $changeLogUuid = $this->createChangeLogEntry($class, 'DELETE', $uuid); |
|
| 645 | + if ($class && $class->hasChangeLog()) { |
|
| 646 | + $changeLogUuid = $this->createChangeLogEntry($class, 'DELETE', $uuid); |
|
| 647 | + } |
|
| 624 | 648 | |
| 625 | 649 | /** ---- KEEP ME ---- |
| 626 | 650 | * don't delete the links so any that haven't been deleted between |
@@ -643,8 +667,9 @@ discard block |
||
| 643 | 667 | public function deleteObjects(array $uuids) |
| 644 | 668 | { |
| 645 | 669 | $objects = $this->getObjectRowsFromIds($uuids); |
| 646 | - if (count($objects) == 0) |
|
| 647 | - return; |
|
| 670 | + if (count($objects) == 0) { |
|
| 671 | + return; |
|
| 672 | + } |
|
| 648 | 673 | |
| 649 | 674 | $foundUuids = []; |
| 650 | 675 | $foundClasses = []; |
@@ -661,8 +686,9 @@ discard block |
||
| 661 | 686 | $deletedUuids[$classType][$obj['_uuid']] = $obj['_uuid']; |
| 662 | 687 | } |
| 663 | 688 | } |
| 664 | - if (count($foundUuids)) |
|
| 665 | - DdsObject::updateAll(['_deleted' => 1, '_updated' => date('Y-m-d H:i:s')], ['_uuid' => $foundUuids]); |
|
| 689 | + if (count($foundUuids)) { |
|
| 690 | + DdsObject::updateAll(['_deleted' => 1, '_updated' => date('Y-m-d H:i:s')], ['_uuid' => $foundUuids]); |
|
| 691 | + } |
|
| 666 | 692 | foreach ($foundClasses as $type => $count) { |
| 667 | 693 | $class = null; |
| 668 | 694 | if ($this->findClass($type, $class)) { |
@@ -670,8 +696,9 @@ discard block |
||
| 670 | 696 | $class->save(); |
| 671 | 697 | // TODO 20200107 Make a bulk call for change log entries |
| 672 | 698 | if ($class->hasChangeLog()) { |
| 673 | - foreach ($deletedUuids[$class->class_type] as $objUuid) |
|
| 674 | - $this->createChangeLogEntry($class, 'DELETE', $objUuid); |
|
| 699 | + foreach ($deletedUuids[$class->class_type] as $objUuid) { |
|
| 700 | + $this->createChangeLogEntry($class, 'DELETE', $objUuid); |
|
| 701 | + } |
|
| 675 | 702 | } |
| 676 | 703 | } |
| 677 | 704 | } |
@@ -698,8 +725,9 @@ discard block |
||
| 698 | 725 | if ($this->getObjectFromId($uuid, $object) && $object->_deleted == 1) { |
| 699 | 726 | $object->_deleted = 0; |
| 700 | 727 | $object->_updated = date('Y-m-d H:i:s'); |
| 701 | - if (!$object->save()) |
|
| 702 | - throw new \RuntimeException("Couldn't undelete the object: " . print_r($object->errors, true)); |
|
| 728 | + if (!$object->save()) { |
|
| 729 | + throw new \RuntimeException("Couldn't undelete the object: " . print_r($object->errors, true)); |
|
| 730 | + } |
|
| 703 | 731 | |
| 704 | 732 | // and update the class object deleted count |
| 705 | 733 | $class = null; |
@@ -708,8 +736,9 @@ discard block |
||
| 708 | 736 | $class->save(); |
| 709 | 737 | |
| 710 | 738 | // see if we need to store the change log |
| 711 | - if ($class->hasChangeLog()) |
|
| 712 | - $changeLogUuid = $this->createChangeLogEntry($class, 'UNDELETE', $uuid); |
|
| 739 | + if ($class->hasChangeLog()) { |
|
| 740 | + $changeLogUuid = $this->createChangeLogEntry($class, 'UNDELETE', $uuid); |
|
| 741 | + } |
|
| 713 | 742 | } |
| 714 | 743 | $this->clearCaches(); |
| 715 | 744 | } |
@@ -724,8 +753,9 @@ discard block |
||
| 724 | 753 | if ($this->getObjectFromId($uuid, $object)) { |
| 725 | 754 | $class = null; |
| 726 | 755 | $this->findClass($object['_class_type'], $class); |
| 727 | - if ($class && $class->hasChangeLog()) |
|
| 728 | - $originalValues = $this->getObject($uuid); |
|
| 756 | + if ($class && $class->hasChangeLog()) { |
|
| 757 | + $originalValues = $this->getObject($uuid); |
|
| 758 | + } |
|
| 729 | 759 | |
| 730 | 760 | // delete any object table data |
| 731 | 761 | $table = $this->getTableFromClassType($object['_class_type']); |
@@ -741,8 +771,9 @@ discard block |
||
| 741 | 771 | // then if ok, decrement the class's object counts |
| 742 | 772 | if ($class) { |
| 743 | 773 | $class->count_total = max(0, $class->count_total - 1); |
| 744 | - if ($object['_deleted'] == 1) |
|
| 745 | - $class->count_deleted = max(0, $class->count_deleted - 1); |
|
| 774 | + if ($object['_deleted'] == 1) { |
|
| 775 | + $class->count_deleted = max(0, $class->count_deleted - 1); |
|
| 776 | + } |
|
| 746 | 777 | $class->save(); |
| 747 | 778 | } |
| 748 | 779 | |
@@ -750,8 +781,9 @@ discard block |
||
| 750 | 781 | DdsLink::deleteAll(['or', ['from_id' => $uuid], ['to_id' => $uuid]]); |
| 751 | 782 | |
| 752 | 783 | // and note this is in the change log |
| 753 | - if ($class && $class->hasChangeLog()) |
|
| 754 | - $changeLogUuid = $this->createChangeLogEntry($class, 'DESTROY', $uuid, $originalValues); |
|
| 784 | + if ($class && $class->hasChangeLog()) { |
|
| 785 | + $changeLogUuid = $this->createChangeLogEntry($class, 'DESTROY', $uuid, $originalValues); |
|
| 786 | + } |
|
| 755 | 787 | |
| 756 | 788 | $this->clearCaches(); |
| 757 | 789 | } |
@@ -763,16 +795,18 @@ discard block |
||
| 763 | 795 | public function destroyObjects(array $uuids) |
| 764 | 796 | { |
| 765 | 797 | $objects = $this->getObjectRowsFromIds($uuids); |
| 766 | - if (count($objects) == 0) |
|
| 767 | - return; |
|
| 798 | + if (count($objects) == 0) { |
|
| 799 | + return; |
|
| 800 | + } |
|
| 768 | 801 | |
| 769 | 802 | $objectUuids = []; |
| 770 | 803 | $objectsDeleted = []; |
| 771 | 804 | $classUuids = []; |
| 772 | 805 | foreach ($objects as $obj) { |
| 773 | 806 | $objectUuids[$obj['_uuid']] = $obj['_uuid']; |
| 774 | - if ($obj['_deleted'] == 1) |
|
| 775 | - $objectsDeleted[$obj['_class_type']][$obj['_uuid']] = $obj['_uuid']; |
|
| 807 | + if ($obj['_deleted'] == 1) { |
|
| 808 | + $objectsDeleted[$obj['_class_type']][$obj['_uuid']] = $obj['_uuid']; |
|
| 809 | + } |
|
| 776 | 810 | $classUuids[$obj['_class_type']][] = $obj['_uuid']; |
| 777 | 811 | } |
| 778 | 812 | |
@@ -799,8 +833,9 @@ discard block |
||
| 799 | 833 | // decrement the class's object counts |
| 800 | 834 | if ($class) { |
| 801 | 835 | $class->count_total = max(0, $class->count_total - count($uuids)); |
| 802 | - if (isset($objectsDeleted[$classType])) |
|
| 803 | - $class->count_deleted = max(0, $class->count_deleted - count($objectsDeleted[$classType])); |
|
| 836 | + if (isset($objectsDeleted[$classType])) { |
|
| 837 | + $class->count_deleted = max(0, $class->count_deleted - count($objectsDeleted[$classType])); |
|
| 838 | + } |
|
| 804 | 839 | $class->save(); |
| 805 | 840 | } |
| 806 | 841 | } |
@@ -852,8 +887,9 @@ discard block |
||
| 852 | 887 | */ |
| 853 | 888 | private function getObjectMapManager() |
| 854 | 889 | { |
| 855 | - if (!$this->_objectMapManager) |
|
| 856 | - $this->_objectMapManager = new DdsObjectMapManager; |
|
| 890 | + if (!$this->_objectMapManager) { |
|
| 891 | + $this->_objectMapManager = new DdsObjectMapManager; |
|
| 892 | + } |
|
| 857 | 893 | return $this->_objectMapManager; |
| 858 | 894 | } |
| 859 | 895 | |
@@ -868,14 +904,16 @@ discard block |
||
| 868 | 904 | // then see if there are any multilinks to extract |
| 869 | 905 | if ($links === null) { |
| 870 | 906 | $objectIds = []; |
| 871 | - foreach ($dataSet as $row) |
|
| 872 | - $objectIds[] = $row['_uuid']; |
|
| 907 | + foreach ($dataSet as $row) { |
|
| 908 | + $objectIds[] = $row['_uuid']; |
|
| 909 | + } |
|
| 873 | 910 | $links = $this->getMembersLinks($objectIds); |
| 874 | 911 | } |
| 875 | 912 | foreach ($dataSet as &$data) { |
| 876 | 913 | // convert full rows to database. Totals are left untouched |
| 877 | - if (isset($data[$classTypeKey])) |
|
| 878 | - $this->convertFromDBToPHP($data, $links[$data['_uuid']], $classTypeKey); |
|
| 914 | + if (isset($data[$classTypeKey])) { |
|
| 915 | + $this->convertFromDBToPHP($data, $links[$data['_uuid']], $classTypeKey); |
|
| 916 | + } |
|
| 879 | 917 | } |
| 880 | 918 | } |
| 881 | 919 | |
@@ -942,8 +980,9 @@ discard block |
||
| 942 | 980 | // a randomly generated resultKey prevents db query chaching. |
| 943 | 981 | $resultKey = $resultKey ? $resultKey : $request['requestKey'] . '_' . $counter; |
| 944 | 982 | $request['resultKey'] = $resultKey; |
| 945 | - if (!array_key_exists($request['requestKey'], self::$_requestResultsCache)) |
|
| 946 | - $this->convertRequestToSql($request); |
|
| 983 | + if (!array_key_exists($request['requestKey'], self::$_requestResultsCache)) { |
|
| 984 | + $this->convertRequestToSql($request); |
|
| 985 | + } |
|
| 947 | 986 | // store the request |
| 948 | 987 | $this->objectRequests[$request['classType']][$resultKey] = $request; |
| 949 | 988 | return $resultKey; |
@@ -1052,8 +1091,9 @@ discard block |
||
| 1052 | 1091 | $join = ['INNER JOIN dds_object `o` on `t`.`_uuid` = `o`.`_uuid`']; |
| 1053 | 1092 | // now see what else needs to be added |
| 1054 | 1093 | foreach ($links as $l) { |
| 1055 | - if (in_array($l, $filterKeys)) |
|
| 1056 | - $join[] = "LEFT JOIN dds_link `link_$l` ON (`link_$l`.`from_id`=`o`.`_uuid` AND `link_$l`.`from_member`='$l')"; |
|
| 1094 | + if (in_array($l, $filterKeys)) { |
|
| 1095 | + $join[] = "LEFT JOIN dds_link `link_$l` ON (`link_$l`.`from_id`=`o`.`_uuid` AND `link_$l`.`from_member`='$l')"; |
|
| 1096 | + } |
|
| 1057 | 1097 | } |
| 1058 | 1098 | return implode(' ', $join); |
| 1059 | 1099 | } |
@@ -1070,11 +1110,13 @@ discard block |
||
| 1070 | 1110 | { |
| 1071 | 1111 | $filterKeys = []; |
| 1072 | 1112 | $notDeleted = '`o`.`_deleted`=0'; |
| 1073 | - if (count($filters) == 0) |
|
| 1074 | - return $includeDeleted ? '' : "WHERE $notDeleted"; |
|
| 1113 | + if (count($filters) == 0) { |
|
| 1114 | + return $includeDeleted ? '' : "WHERE $notDeleted"; |
|
| 1115 | + } |
|
| 1075 | 1116 | $this->createFilterClause($filters, $links, $filterKeys); |
| 1076 | - if (!$includeDeleted) |
|
| 1077 | - return "WHERE $notDeleted AND ($filters[sql])"; |
|
| 1117 | + if (!$includeDeleted) { |
|
| 1118 | + return "WHERE $notDeleted AND ($filters[sql])"; |
|
| 1119 | + } |
|
| 1078 | 1120 | return "WHERE $filters[sql]"; |
| 1079 | 1121 | } |
| 1080 | 1122 | |
@@ -1092,8 +1134,9 @@ discard block |
||
| 1092 | 1134 | // filter down until we hit the actual filters |
| 1093 | 1135 | if (is_array($filters[0])) { |
| 1094 | 1136 | foreach ($filters as $k => &$filter) { |
| 1095 | - if ($k === 'logic') |
|
| 1096 | - continue; |
|
| 1137 | + if ($k === 'logic') { |
|
| 1138 | + continue; |
|
| 1139 | + } |
|
| 1097 | 1140 | $this->createFilterClause($filter, $links, $filterKeys); |
| 1098 | 1141 | } |
| 1099 | 1142 | |
@@ -1105,25 +1148,28 @@ discard block |
||
| 1105 | 1148 | // in which case we combine those with to get the filterSql |
| 1106 | 1149 | $filterSql = []; |
| 1107 | 1150 | foreach ($filters as $k => &$filter) { |
| 1108 | - if ($k === 'logic') |
|
| 1109 | - continue; |
|
| 1151 | + if ($k === 'logic') { |
|
| 1152 | + continue; |
|
| 1153 | + } |
|
| 1110 | 1154 | // use the logic keys if any for the items - these can be in position 3 |
| 1111 | 1155 | // for most operators and position 2 for operators that don't take a key |
| 1112 | 1156 | if ($this->operatorTakesObject($filter[1])) { |
| 1113 | - if (isset($filter[3])) |
|
| 1114 | - $filterSql[$filter[3]] = $filter['itemSql']; |
|
| 1115 | - else |
|
| 1116 | - $filterSql[] = $filter['itemSql']; |
|
| 1157 | + if (isset($filter[3])) { |
|
| 1158 | + $filterSql[$filter[3]] = $filter['itemSql']; |
|
| 1159 | + } else { |
|
| 1160 | + $filterSql[] = $filter['itemSql']; |
|
| 1161 | + } |
|
| 1117 | 1162 | } else { |
| 1118 | - if (isset($filter[2])) |
|
| 1119 | - $filterSql[$filter[2]] = $filter['itemSql']; |
|
| 1120 | - else |
|
| 1121 | - $filterSql[] = $filter['itemSql']; |
|
| 1163 | + if (isset($filter[2])) { |
|
| 1164 | + $filterSql[$filter[2]] = $filter['itemSql']; |
|
| 1165 | + } else { |
|
| 1166 | + $filterSql[] = $filter['itemSql']; |
|
| 1167 | + } |
|
| 1122 | 1168 | } |
| 1123 | 1169 | } |
| 1124 | - if (empty($filters['logic'])) |
|
| 1125 | - $filters['filterSql'] = $filters['sql'] = implode(' AND ', $filterSql); |
|
| 1126 | - else { |
|
| 1170 | + if (empty($filters['logic'])) { |
|
| 1171 | + $filters['filterSql'] = $filters['sql'] = implode(' AND ', $filterSql); |
|
| 1172 | + } else { |
|
| 1127 | 1173 | // make sure we test logic filters in order from longest key to shortest key |
| 1128 | 1174 | // otherwise we can end up with subkeys screwing things up |
| 1129 | 1175 | $orderedKeys = array_map('strlen', array_keys($filterSql)); |
@@ -1135,8 +1181,9 @@ discard block |
||
| 1135 | 1181 | // double conversion, |
| 1136 | 1182 | $keys = array_keys($filterSql); |
| 1137 | 1183 | $keys2hashed = array(); |
| 1138 | - foreach ($keys as $k) |
|
| 1139 | - $keys2hashed[$k] = md5($k); |
|
| 1184 | + foreach ($keys as $k) { |
|
| 1185 | + $keys2hashed[$k] = md5($k); |
|
| 1186 | + } |
|
| 1140 | 1187 | $logicPass1 = str_replace($keys, $keys2hashed, $filters['logic']); |
| 1141 | 1188 | $filters['filterSql'] = $filters['sql'] = str_replace($keys2hashed, array_values($filterSql), $logicPass1); |
| 1142 | 1189 | } |
@@ -1159,9 +1206,9 @@ discard block |
||
| 1159 | 1206 | // |
| 1160 | 1207 | $filter = (in_array($filters[0], $links) ? "`link_{$filters[0]}`.`to_id`" : $this->quoteField($filters[0])); |
| 1161 | 1208 | $filterKeys[$filters[0]] = $filters[0]; |
| 1162 | - if ($this->operatorTakesObject($filters[1]) && isset($filters[2])) |
|
| 1163 | - $filters['itemSql'] = $filters['sql'] = "$filter " . $this->prepareForPDO($filters[1], $filters[2]); |
|
| 1164 | - else { |
|
| 1209 | + if ($this->operatorTakesObject($filters[1]) && isset($filters[2])) { |
|
| 1210 | + $filters['itemSql'] = $filters['sql'] = "$filter " . $this->prepareForPDO($filters[1], $filters[2]); |
|
| 1211 | + } else { |
|
| 1165 | 1212 | $filters['itemSql'] = $filters['sql'] = "$filter $filters[1]"; |
| 1166 | 1213 | } |
| 1167 | 1214 | } |
@@ -1170,21 +1217,25 @@ discard block |
||
| 1170 | 1217 | { |
| 1171 | 1218 | if (is_array($value)) { |
| 1172 | 1219 | $pdoValues = []; |
| 1173 | - if (!in_array($operator, ['=', '!=', 'IN', 'NOT IN'])) |
|
| 1174 | - throw new \InvalidArgumentException("Daedalus: Cannot pass an *array* of values with an operator of $operator"); |
|
| 1220 | + if (!in_array($operator, ['=', '!=', 'IN', 'NOT IN'])) { |
|
| 1221 | + throw new \InvalidArgumentException("Daedalus: Cannot pass an *array* of values with an operator of $operator"); |
|
| 1222 | + } |
|
| 1175 | 1223 | foreach ($value as $v) { |
| 1176 | - if (is_array($v)) |
|
| 1177 | - throw new \InvalidArgumentException("Daedalus: Cannot pass an *array* of *array* of values as filters (silly billy). You passed " . print_r($value, true)); |
|
| 1224 | + if (is_array($v)) { |
|
| 1225 | + throw new \InvalidArgumentException("Daedalus: Cannot pass an *array* of *array* of values as filters (silly billy). You passed " . print_r($value, true)); |
|
| 1226 | + } |
|
| 1178 | 1227 | $count = count($this->boundValues); |
| 1179 | 1228 | $variable = ":var{$count}end"; |
| 1180 | 1229 | $this->boundValues[$variable] = $v; |
| 1181 | 1230 | $pdoValues[] = $variable; |
| 1182 | 1231 | } |
| 1183 | 1232 | // converts equals to ins and outs |
| 1184 | - if ($operator == '=') |
|
| 1185 | - $operator = 'IN'; |
|
| 1186 | - if ($operator == '!=') |
|
| 1187 | - $operator = 'NOT IN'; |
|
| 1233 | + if ($operator == '=') { |
|
| 1234 | + $operator = 'IN'; |
|
| 1235 | + } |
|
| 1236 | + if ($operator == '!=') { |
|
| 1237 | + $operator = 'NOT IN'; |
|
| 1238 | + } |
|
| 1188 | 1239 | return "$operator (" . implode(',', $pdoValues) . ')'; |
| 1189 | 1240 | } else { |
| 1190 | 1241 | $count = count($this->boundValues); |
@@ -1208,8 +1259,9 @@ discard block |
||
| 1208 | 1259 | */ |
| 1209 | 1260 | private function extractOrderClause($order) |
| 1210 | 1261 | { |
| 1211 | - if (count($order) == 0) |
|
| 1212 | - return ''; |
|
| 1262 | + if (count($order) == 0) { |
|
| 1263 | + return ''; |
|
| 1264 | + } |
|
| 1213 | 1265 | $clause = []; |
| 1214 | 1266 | foreach ($order as $o => $d) { |
| 1215 | 1267 | // if any of the order clauses are RAND then replace whole clause |
@@ -1218,10 +1270,11 @@ discard block |
||
| 1218 | 1270 | break; |
| 1219 | 1271 | } |
| 1220 | 1272 | // allow negative ordering in mysql for nulls last |
| 1221 | - if (strpos($o, '-') === 0) |
|
| 1222 | - $clause[] = '-' . substr($o, 1) . " $d"; |
|
| 1223 | - else |
|
| 1224 | - $clause[] = "$o $d"; |
|
| 1273 | + if (strpos($o, '-') === 0) { |
|
| 1274 | + $clause[] = '-' . substr($o, 1) . " $d"; |
|
| 1275 | + } else { |
|
| 1276 | + $clause[] = "$o $d"; |
|
| 1277 | + } |
|
| 1225 | 1278 | } |
| 1226 | 1279 | return 'ORDER BY ' . implode(', ', $clause); |
| 1227 | 1280 | } |
@@ -1233,8 +1286,9 @@ discard block |
||
| 1233 | 1286 | */ |
| 1234 | 1287 | private function extractLimitClause($limit) |
| 1235 | 1288 | { |
| 1236 | - if (count($limit) == 0) |
|
| 1237 | - return ''; |
|
| 1289 | + if (count($limit) == 0) { |
|
| 1290 | + return ''; |
|
| 1291 | + } |
|
| 1238 | 1292 | return "LIMIT $limit[start], $limit[length]"; |
| 1239 | 1293 | } |
| 1240 | 1294 | |
@@ -1245,8 +1299,9 @@ discard block |
||
| 1245 | 1299 | */ |
| 1246 | 1300 | private function setMembersLinks($objectsLinks, $chunkSize) |
| 1247 | 1301 | { |
| 1248 | - if (count($objectsLinks) === 0) |
|
| 1249 | - return 0; |
|
| 1302 | + if (count($objectsLinks) === 0) { |
|
| 1303 | + return 0; |
|
| 1304 | + } |
|
| 1250 | 1305 | $totalCount = 0; |
| 1251 | 1306 | $db = neon()->db; |
| 1252 | 1307 | $ddsLink = DdsLink::tableName(); |
@@ -1256,15 +1311,18 @@ discard block |
||
| 1256 | 1311 | $deleteLinkClauses = []; |
| 1257 | 1312 | foreach ($chunkData as $fromUuid => $toMemberLinks) { |
| 1258 | 1313 | // check you've been supplied with rinky dinky data |
| 1259 | - if (!$this->isUUID($fromUuid)) |
|
| 1260 | - throw new \InvalidArgumentException("The fromUuid should be a UUID64. You passed in $fromUuid"); |
|
| 1314 | + if (!$this->isUUID($fromUuid)) { |
|
| 1315 | + throw new \InvalidArgumentException("The fromUuid should be a UUID64. You passed in $fromUuid"); |
|
| 1316 | + } |
|
| 1261 | 1317 | foreach ($toMemberLinks as $member => $toLinks) { |
| 1262 | - if (!is_array($toLinks)) |
|
| 1263 | - $toLinks = [$toLinks]; |
|
| 1318 | + if (!is_array($toLinks)) { |
|
| 1319 | + $toLinks = [$toLinks]; |
|
| 1320 | + } |
|
| 1264 | 1321 | // remove any empty toLinks that might have snuck through |
| 1265 | 1322 | $toLinks = array_filter($toLinks); |
| 1266 | - if (!$this->areUUIDs($toLinks)) |
|
| 1267 | - throw new \InvalidArgumentException("The toMemberLinks should be UUID64s. You passed in " . print_r($toLinks, true)); |
|
| 1323 | + if (!$this->areUUIDs($toLinks)) { |
|
| 1324 | + throw new \InvalidArgumentException("The toMemberLinks should be UUID64s. You passed in " . print_r($toLinks, true)); |
|
| 1325 | + } |
|
| 1268 | 1326 | $toLinks = array_unique($toLinks); |
| 1269 | 1327 | |
| 1270 | 1328 | // |
@@ -1279,8 +1337,9 @@ discard block |
||
| 1279 | 1337 | |
| 1280 | 1338 | // prepare the new links ready for bulk insert |
| 1281 | 1339 | $count += count($toLinks); |
| 1282 | - foreach ($toLinks as $toLink) |
|
| 1283 | - $batchInsert[] = ['from_id' => $fromUuid, 'from_member' => $member, 'to_id' => $toLink]; |
|
| 1340 | + foreach ($toLinks as $toLink) { |
|
| 1341 | + $batchInsert[] = ['from_id' => $fromUuid, 'from_member' => $member, 'to_id' => $toLink]; |
|
| 1342 | + } |
|
| 1284 | 1343 | } |
| 1285 | 1344 | } |
| 1286 | 1345 | if (count($deleteLinkClauses)) { |
@@ -1289,10 +1348,12 @@ discard block |
||
| 1289 | 1348 | } |
| 1290 | 1349 | |
| 1291 | 1350 | $insertedCount = 0; |
| 1292 | - if (count($batchInsert)) |
|
| 1293 | - $insertedCount = $db->createCommand()->batchInsert($ddsLink, ['from_id', 'from_member', 'to_id'], $batchInsert)->execute(); |
|
| 1294 | - if (YII_DEBUG && $insertedCount !== $count) |
|
| 1295 | - throw new \Exception("The link insertion failed - $count items should have been inserted vs $insertedCount actual"); |
|
| 1351 | + if (count($batchInsert)) { |
|
| 1352 | + $insertedCount = $db->createCommand()->batchInsert($ddsLink, ['from_id', 'from_member', 'to_id'], $batchInsert)->execute(); |
|
| 1353 | + } |
|
| 1354 | + if (YII_DEBUG && $insertedCount !== $count) { |
|
| 1355 | + throw new \Exception("The link insertion failed - $count items should have been inserted vs $insertedCount actual"); |
|
| 1356 | + } |
|
| 1296 | 1357 | $totalCount += $count; |
| 1297 | 1358 | } |
| 1298 | 1359 | return $totalCount; |
@@ -1333,8 +1394,9 @@ discard block |
||
| 1333 | 1394 | */ |
| 1334 | 1395 | protected function getMembersLinks(array $objectIds) |
| 1335 | 1396 | { |
| 1336 | - if (empty($objectIds)) |
|
| 1337 | - return []; |
|
| 1397 | + if (empty($objectIds)) { |
|
| 1398 | + return []; |
|
| 1399 | + } |
|
| 1338 | 1400 | $objectIds = array_unique($objectIds); |
| 1339 | 1401 | sort($objectIds, SORT_STRING); |
| 1340 | 1402 | $cacheKey = md5(serialize($objectIds)); |
@@ -1346,8 +1408,9 @@ discard block |
||
| 1346 | 1408 | ->asArray() |
| 1347 | 1409 | ->all(); |
| 1348 | 1410 | $multilinks = array_fill_keys($objectIds, []); |
| 1349 | - foreach ($rows as $row) |
|
| 1350 | - $multilinks[$row['from_id']][$row['from_member']][] = $row['to_id']; |
|
| 1411 | + foreach ($rows as $row) { |
|
| 1412 | + $multilinks[$row['from_id']][$row['from_member']][] = $row['to_id']; |
|
| 1413 | + } |
|
| 1351 | 1414 | self::$_linkResultsCache[$cacheKey] = $multilinks; |
| 1352 | 1415 | } |
| 1353 | 1416 | return self::$_linkResultsCache[$cacheKey]; |
@@ -1364,8 +1427,9 @@ discard block |
||
| 1364 | 1427 | private function createChangeLogEntry($class, $changeKey, $objectUuid, $originalValues = [], $newValues = []) |
| 1365 | 1428 | { |
| 1366 | 1429 | static $changeLog = null; |
| 1367 | - if (!$changeLog) |
|
| 1368 | - $changeLog = neon('dds')->IDdsChangeLogManagement; |
|
| 1430 | + if (!$changeLog) { |
|
| 1431 | + $changeLog = neon('dds')->IDdsChangeLogManagement; |
|
| 1432 | + } |
|
| 1369 | 1433 | return $changeLog->addLogEntry($objectUuid, $class->toArray(), $changeKey, $originalValues, $newValues); |
| 1370 | 1434 | } |
| 1371 | 1435 | |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | foreach ($appSettings as $key => $value) { |
| 67 | 67 | // if the fields value is valid then save it |
| 68 | 68 | if ($appForm->getField($key)->validate()) { |
| 69 | - $saved = $this->getSettingsManager()->set($appKey, $key, $value); |
|
| 69 | + $saved = $this->getSettingsManager()->set($appKey, $key, $value); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -55,7 +55,9 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public static function editor($params, $content, \Smarty_Internal_Template $template, &$repeat) |
| 57 | 57 | { |
| 58 | - if ($repeat) return; |
|
| 58 | + if ($repeat) { |
|
| 59 | + return; |
|
| 60 | + } |
|
| 59 | 61 | $id = Arr::get($params, 'id', neon()->cms->getPage()->getId()); |
| 60 | 62 | $dbContent = neon()->getCms()->getICmsStaticData()->getStaticContent($id, null); |
| 61 | 63 | if (!$dbContent) { |
@@ -73,7 +75,9 @@ discard block |
||
| 73 | 75 | $element->normalize(); |
| 74 | 76 | |
| 75 | 77 | $dom = simplexml_import_dom($x); |
| 76 | - foreach($dom as $d) dp($d); |
|
| 78 | + foreach($dom as $d) { |
|
| 79 | + dp($d); |
|
| 80 | + } |
|
| 77 | 81 | exit; |
| 78 | 82 | |
| 79 | 83 | |
@@ -168,7 +172,9 @@ discard block |
||
| 168 | 172 | unset($props['children']); |
| 169 | 173 | $formatParams = ''; |
| 170 | 174 | foreach($props as $key => $value) { |
| 171 | - if (is_array($value)) $value = var_export($value, true); |
|
| 175 | + if (is_array($value)) { |
|
| 176 | + $value = var_export($value, true); |
|
| 177 | + } |
|
| 172 | 178 | $formatParams .= $key.'="'. $value .'" '; |
| 173 | 179 | } |
| 174 | 180 | return $formatParams; |