@@ -171,8 +171,9 @@ |
||
| 171 | 171 | public static function endProfile($token=null, $category = 'application') |
| 172 | 172 | { |
| 173 | 173 | if (neon()->debug) { |
| 174 | - if ($token === null) |
|
| 175 | - list($token, $category) = array_pop(self::$_logStack); |
|
| 174 | + if ($token === null) { |
|
| 175 | + list($token, $category) = array_pop(self::$_logStack); |
|
| 176 | + } |
|
| 176 | 177 | parent::endProfile($token, $category); |
| 177 | 178 | } |
| 178 | 179 | } |
@@ -34,8 +34,9 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public static function getNeonSecret() |
| 36 | 36 | { |
| 37 | - if (empty(env('NEON_SECRET'))) |
|
| 38 | - Env::createEnvironmentVariable('NEON_SECRET'); |
|
| 37 | + if (empty(env('NEON_SECRET'))) { |
|
| 38 | + Env::createEnvironmentVariable('NEON_SECRET'); |
|
| 39 | + } |
|
| 39 | 40 | return env('NEON_SECRET'); |
| 40 | 41 | } |
| 41 | 42 | |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | */ |
| 46 | 47 | public static function getNeonEncryptionKey() |
| 47 | 48 | { |
| 48 | - if (empty(env('NEON_ENCRYPTION_KEY'))) |
|
| 49 | - Env::createEnvironmentVariable('NEON_ENCRYPTION_KEY'); |
|
| 49 | + if (empty(env('NEON_ENCRYPTION_KEY'))) { |
|
| 50 | + Env::createEnvironmentVariable('NEON_ENCRYPTION_KEY'); |
|
| 51 | + } |
|
| 50 | 52 | return env('NEON_ENCRYPTION_KEY'); |
| 51 | 53 | } |
| 52 | 54 | |
@@ -114,8 +116,9 @@ discard block |
||
| 114 | 116 | defined('DIR_SYSTEM') || define('DIR_SYSTEM', DIR_ROOT . '/system'); |
| 115 | 117 | |
| 116 | 118 | Env::environment(); |
| 117 | - if (!class_exists('Neon')) |
|
| 118 | - require DIR_NEON.'/core/Yii.php'; |
|
| 119 | + if (!class_exists('Neon')) { |
|
| 120 | + require DIR_NEON.'/core/Yii.php'; |
|
| 121 | + } |
|
| 119 | 122 | |
| 120 | 123 | \Neon::setAlias('neon', DIR_NEON); |
| 121 | 124 | \Neon::setAlias('root', DIR_ROOT); |
@@ -159,8 +162,9 @@ discard block |
||
| 159 | 162 | private static function createEnvironmentVariable($name, $saveToEnvFile=true) |
| 160 | 163 | { |
| 161 | 164 | $value = Hash::uuid64().Hash::uuid64().Hash::uuid64().Hash::uuid64(); |
| 162 | - if ($saveToEnvFile && file_exists(DIR_CONFIG.'/env.ini')) |
|
| 163 | - file_put_contents(DIR_CONFIG.'/env.ini', PHP_EOL."$name = '$value'", FILE_APPEND | LOCK_EX); |
|
| 165 | + if ($saveToEnvFile && file_exists(DIR_CONFIG.'/env.ini')) { |
|
| 166 | + file_put_contents(DIR_CONFIG.'/env.ini', PHP_EOL."$name = '$value'", FILE_APPEND | LOCK_EX); |
|
| 167 | + } |
|
| 164 | 168 | static::setEnvironmentVariable($name, $value, true); |
| 165 | 169 | } |
| 166 | 170 | |
@@ -102,8 +102,9 @@ |
||
| 102 | 102 | public function init() |
| 103 | 103 | { |
| 104 | 104 | parent::init(); |
| 105 | - if ($this->isInstalled() && neon()->dev) |
|
| 106 | - neon()->dev->debugBootstrap(); |
|
| 105 | + if ($this->isInstalled() && neon()->dev) { |
|
| 106 | + neon()->dev->debugBootstrap(); |
|
| 107 | + } |
|
| 107 | 108 | } |
| 108 | 109 | |
| 109 | 110 | /** |
@@ -19,8 +19,9 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | public static function get($label='') |
| 21 | 21 | { |
| 22 | - if (self::$mock===null) |
|
| 23 | - self::$mock = new self(); |
|
| 22 | + if (self::$mock===null) { |
|
| 23 | + self::$mock = new self(); |
|
| 24 | + } |
|
| 24 | 25 | self::$mock->label = $label; |
| 25 | 26 | return self::$mock; |
| 26 | 27 | } |
@@ -148,8 +148,9 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | $this->_classType = $value; |
| 150 | 150 | // Set a default title |
| 151 | - if ($this->title === null) |
|
| 152 | - $this->title = $this->_classType; |
|
| 151 | + if ($this->title === null) { |
|
| 152 | + $this->title = $this->_classType; |
|
| 153 | + } |
|
| 153 | 154 | } |
| 154 | 155 | |
| 155 | 156 | /** |
@@ -191,18 +192,21 @@ discard block |
||
| 191 | 192 | parent::init(); |
| 192 | 193 | // don't configure the grid if the class type has not been set! |
| 193 | 194 | if ($this->_classType === null) { |
| 194 | - if (neon()->debug) |
|
| 195 | - throw new \RuntimeException('You need to configure the grid class type before calling init'); |
|
| 195 | + if (neon()->debug) { |
|
| 196 | + throw new \RuntimeException('You need to configure the grid class type before calling init'); |
|
| 197 | + } |
|
| 196 | 198 | return null; |
| 197 | 199 | } |
| 198 | 200 | |
| 199 | 201 | $this->addColumnsFromClassMembers(); |
| 200 | 202 | $this->addDdsObjectColumns(); |
| 201 | 203 | |
| 202 | - if ($this->useActiveScope) |
|
| 203 | - $this->addScope('active', 'Active'); |
|
| 204 | - if ($this->useDeletedScope) |
|
| 205 | - $this->addScope('deleted', 'Deleted'); |
|
| 204 | + if ($this->useActiveScope) { |
|
| 205 | + $this->addScope('active', 'Active'); |
|
| 206 | + } |
|
| 207 | + if ($this->useDeletedScope) { |
|
| 208 | + $this->addScope('deleted', 'Deleted'); |
|
| 209 | + } |
|
| 206 | 210 | } |
| 207 | 211 | |
| 208 | 212 | /** |
@@ -368,8 +372,9 @@ discard block |
||
| 368 | 372 | 'class' => 'neon\core\grid\column\DefinitionColumn', |
| 369 | 373 | 'member' => new $columnType($member), |
| 370 | 374 | ]; |
| 371 | - if (is_array($config)) |
|
| 372 | - $colConfig = array_merge($colConfig, $config); |
|
| 375 | + if (is_array($config)) { |
|
| 376 | + $colConfig = array_merge($colConfig, $config); |
|
| 377 | + } |
|
| 373 | 378 | return $this->addColumn($member, $colConfig); |
| 374 | 379 | } |
| 375 | 380 | |
@@ -379,8 +384,9 @@ discard block |
||
| 379 | 384 | */ |
| 380 | 385 | public function ddsLoadGrid($classType, $includeDeleted=false, $pageSize=50) |
| 381 | 386 | { |
| 382 | - if ($this->title == null) |
|
| 383 | - $this->title = $classType; |
|
| 387 | + if ($this->title == null) { |
|
| 388 | + $this->title = $classType; |
|
| 389 | + } |
|
| 384 | 390 | // TODO: should be in constructor can't create a DDS grid without the DDS class ref |
| 385 | 391 | $this->classType = $classType; |
| 386 | 392 | |
@@ -42,10 +42,12 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function init() |
| 44 | 44 | { |
| 45 | - if (empty($this->phoebeType)) |
|
| 46 | - throw new \RuntimeException('PhoebeDataProvider: the phoebe type has not been set. It needs to be set on construction'); |
|
| 47 | - if (empty($this->classType)) |
|
| 48 | - throw new \RuntimeException('PhoebeDataProvider: the phoebe class type has not been set. It needs to be set on construction'); |
|
| 45 | + if (empty($this->phoebeType)) { |
|
| 46 | + throw new \RuntimeException('PhoebeDataProvider: the phoebe type has not been set. It needs to be set on construction'); |
|
| 47 | + } |
|
| 48 | + if (empty($this->classType)) { |
|
| 49 | + throw new \RuntimeException('PhoebeDataProvider: the phoebe class type has not been set. It needs to be set on construction'); |
|
| 50 | + } |
|
| 49 | 51 | } |
| 50 | 52 | |
| 51 | 53 | /** |
@@ -142,8 +144,9 @@ discard block |
||
| 142 | 144 | */ |
| 143 | 145 | protected function getFormDefinition() |
| 144 | 146 | { |
| 145 | - if ($this->formDefinition == null) |
|
| 146 | - $this->formDefinition = neon('phoebe')->getFormDefinition($this->phoebeType, $this->classType); |
|
| 147 | + if ($this->formDefinition == null) { |
|
| 148 | + $this->formDefinition = neon('phoebe')->getFormDefinition($this->phoebeType, $this->classType); |
|
| 149 | + } |
|
| 147 | 150 | return $this->formDefinition; |
| 148 | 151 | } |
| 149 | 152 | |
@@ -40,7 +40,8 @@ |
||
| 40 | 40 | public function __clone() |
| 41 | 41 | { |
| 42 | 42 | parent::__clone(); |
| 43 | - if ($this->_queryBuilder) |
|
| 44 | - $this->_queryBuilder = clone $this->_queryBuilder; |
|
| 43 | + if ($this->_queryBuilder) { |
|
| 44 | + $this->_queryBuilder = clone $this->_queryBuilder; |
|
| 45 | + } |
|
| 45 | 46 | } |
| 46 | 47 | } |
| 47 | 48 | \ No newline at end of file |
@@ -105,8 +105,9 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function getEmptyCellDisplay() |
| 107 | 107 | { |
| 108 | - if ($this->_emptyCellDisplay !== null) |
|
| 109 | - return $this->_emptyCellDisplay; |
|
| 108 | + if ($this->_emptyCellDisplay !== null) { |
|
| 109 | + return $this->_emptyCellDisplay; |
|
| 110 | + } |
|
| 110 | 111 | return $this->getGrid()->emptyCellDisplay; |
| 111 | 112 | } |
| 112 | 113 | |
@@ -437,10 +438,12 @@ discard block |
||
| 437 | 438 | public function renderHeaderCell() |
| 438 | 439 | { |
| 439 | 440 | $options = $this->getHeaderCellAttributes(); |
| 440 | - if ($this->grid->hasSort($this->key)) |
|
| 441 | - Html::addCssClass($options, ($this->grid->hasSortDescending() ? 'desc' : 'asc')); |
|
| 442 | - if (trim($this->width) != '') |
|
| 443 | - Html::addCssStyle($options, ["width" => $this->width]); |
|
| 441 | + if ($this->grid->hasSort($this->key)) { |
|
| 442 | + Html::addCssClass($options, ($this->grid->hasSortDescending() ? 'desc' : 'asc')); |
|
| 443 | + } |
|
| 444 | + if (trim($this->width) != '') { |
|
| 445 | + Html::addCssStyle($options, ["width" => $this->width]); |
|
| 446 | + } |
|
| 444 | 447 | Html::addCssStyle($options, $this->_style); |
| 445 | 448 | |
| 446 | 449 | return Html::tag('th', $this->renderHeaderCellContent(), $options); |
@@ -451,8 +454,9 @@ discard block |
||
| 451 | 454 | */ |
| 452 | 455 | public function renderHeaderCellContent() |
| 453 | 456 | { |
| 454 | - if (!$this->isSortable()) |
|
| 455 | - return $this->getTitle(); |
|
| 457 | + if (!$this->isSortable()) { |
|
| 458 | + return $this->getTitle(); |
|
| 459 | + } |
|
| 456 | 460 | $sort = ''; |
| 457 | 461 | if ($this->grid->hasSort($this->key)) { |
| 458 | 462 | $sort = $this->grid->hasSortDescending() ? ' - ' : ' + '; |
@@ -482,10 +486,12 @@ discard block |
||
| 482 | 486 | */ |
| 483 | 487 | public function renderFilterCellContent() |
| 484 | 488 | { |
| 485 | - if ($this->filter === false) |
|
| 486 | - return ''; |
|
| 487 | - if (!$this->getGrid()->getFilterForm()->hasField($this->getKey())) |
|
| 488 | - return ''; |
|
| 489 | + if ($this->filter === false) { |
|
| 490 | + return ''; |
|
| 491 | + } |
|
| 492 | + if (!$this->getGrid()->getFilterForm()->hasField($this->getKey())) { |
|
| 493 | + return ''; |
|
| 494 | + } |
|
| 489 | 495 | $field = $this->getGrid()->getFilterForm()->getField($this->getKey()); |
| 490 | 496 | // remove any automatic validators |
| 491 | 497 | $field->setValidators([], true); |
@@ -513,8 +519,9 @@ discard block |
||
| 513 | 519 | public function getFilterField() |
| 514 | 520 | { |
| 515 | 521 | $field = $this->getBaseFilterField(); |
| 516 | - foreach($this->filterFieldConfig as $key => $value) |
|
| 517 | - $field[$key] = $value; |
|
| 522 | + foreach($this->filterFieldConfig as $key => $value) { |
|
| 523 | + $field[$key] = $value; |
|
| 524 | + } |
|
| 518 | 525 | return $field; |
| 519 | 526 | } |
| 520 | 527 | |
@@ -530,8 +537,9 @@ discard block |
||
| 530 | 537 | public function setMemberConfig($config) |
| 531 | 538 | { |
| 532 | 539 | foreach($config as $key => $value) { |
| 533 | - if (isset($this->member->$key)) |
|
| 534 | - $this->member->$key = $value; |
|
| 540 | + if (isset($this->member->$key)) { |
|
| 541 | + $this->member->$key = $value; |
|
| 542 | + } |
|
| 535 | 543 | } |
| 536 | 544 | return $this; |
| 537 | 545 | } |
@@ -709,7 +717,9 @@ discard block |
||
| 709 | 717 | $out = '<div class="neonGrid_rowActions">'; |
| 710 | 718 | $i = 0; |
| 711 | 719 | foreach($this->_actions as $actionKey => $linkOptions) { |
| 712 | - if ($i > 0) $out .= ' | '; |
|
| 720 | + if ($i > 0) { |
|
| 721 | + $out .= ' | '; |
|
| 722 | + } |
|
| 713 | 723 | if (isset($linkOptions['function'])) { |
| 714 | 724 | $func = $linkOptions['function']; |
| 715 | 725 | $out .= $this->callFunction($func, [$model, $key, $index]); |
@@ -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 | } |
@@ -956,8 +965,9 @@ discard block |
||
| 956 | 965 | public function processSearch() |
| 957 | 966 | { |
| 958 | 967 | $data = $this->getGridData(); |
| 959 | - if (!isset($data['filter'])) |
|
| 960 | - return; |
|
| 968 | + if (!isset($data['filter'])) { |
|
| 969 | + return; |
|
| 970 | + } |
|
| 961 | 971 | foreach ($this->getColumns() as $key => $column) { |
| 962 | 972 | // check there is a form filter field |
| 963 | 973 | // check that the filter field has request data |
@@ -1041,8 +1051,9 @@ discard block |
||
| 1041 | 1051 | */ |
| 1042 | 1052 | public function getColumn($columnKey) |
| 1043 | 1053 | { |
| 1044 | - if (!isset($this->_columns[$columnKey])) |
|
| 1045 | - throw new \Exception("No column with key '$columnKey' exists in the grid"); |
|
| 1054 | + if (!isset($this->_columns[$columnKey])) { |
|
| 1055 | + throw new \Exception("No column with key '$columnKey' exists in the grid"); |
|
| 1056 | + } |
|
| 1046 | 1057 | return $this->_columns[$columnKey]; |
| 1047 | 1058 | } |
| 1048 | 1059 | |
@@ -1133,8 +1144,9 @@ discard block |
||
| 1133 | 1144 | { |
| 1134 | 1145 | $columns = []; |
| 1135 | 1146 | foreach($this->getColumns() as $key => $column) { |
| 1136 | - if ($column->visible) |
|
| 1137 | - $columns[$key] = $column; |
|
| 1147 | + if ($column->visible) { |
|
| 1148 | + $columns[$key] = $column; |
|
| 1149 | + } |
|
| 1138 | 1150 | } |
| 1139 | 1151 | return $columns; |
| 1140 | 1152 | } |
@@ -1179,8 +1191,9 @@ discard block |
||
| 1179 | 1191 | */ |
| 1180 | 1192 | public function getIndexColumn() |
| 1181 | 1193 | { |
| 1182 | - if (!isset($this->_columns[$this->_indexedByColumn])) |
|
| 1183 | - throw new \Exception("No index column exists with key '$this->_indexedByColumn'."); |
|
| 1194 | + if (!isset($this->_columns[$this->_indexedByColumn])) { |
|
| 1195 | + throw new \Exception("No index column exists with key '$this->_indexedByColumn'."); |
|
| 1196 | + } |
|
| 1184 | 1197 | return $this->_columns[$this->_indexedByColumn]; |
| 1185 | 1198 | } |
| 1186 | 1199 | |
@@ -1242,8 +1255,9 @@ discard block |
||
| 1242 | 1255 | $plain = html_entity_decode( |
| 1243 | 1256 | str_replace(["\n", '"'], ['', '\''], strip_tags($content)), |
| 1244 | 1257 | ENT_HTML401 | ENT_QUOTES | ENT_HTML5); |
| 1245 | - if ($plain === $this->emptyCellDisplay) |
|
| 1246 | - $plain = ''; |
|
| 1258 | + if ($plain === $this->emptyCellDisplay) { |
|
| 1259 | + $plain = ''; |
|
| 1260 | + } |
|
| 1247 | 1261 | return '"'.$plain.'"'; |
| 1248 | 1262 | } |
| 1249 | 1263 | } |
| 1250 | 1264 | \ No newline at end of file |