@@ -17,9 +17,9 @@ |
||
17 | 17 | * @param string $label |
18 | 18 | * @return MockModel|null |
19 | 19 | */ |
20 | - public static function get($label='') |
|
20 | + public static function get($label = '') |
|
21 | 21 | { |
22 | - if (self::$mock===null) |
|
22 | + if (self::$mock === null) |
|
23 | 23 | self::$mock = new self(); |
24 | 24 | self::$mock->label = $label; |
25 | 25 | return self::$mock; |
@@ -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 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | /** |
233 | 233 | * Add the edit and delete DDS object buttons to the grid |
234 | 234 | */ |
235 | - public function addActionButtonColumn($title=false) |
|
235 | + public function addActionButtonColumn($title = false) |
|
236 | 236 | { |
237 | 237 | $buttonCol = $this->addButtonColumn('edit')->setTitle($title); |
238 | 238 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | if ($this->hasScope('deleted') && $this->isScopeActive('deleted')) { |
248 | 248 | if ($this->showGridUndeleteButton) { |
249 | - $buttonCol->addButton('undelete', '','', 'fa fa-undo', 'btn-default', [ |
|
249 | + $buttonCol->addButton('undelete', '', '', 'fa fa-undo', 'btn-default', [ |
|
250 | 250 | 'data-toggle' => 'tooltip', |
251 | 251 | 'title' => 'Restore', |
252 | 252 | 'data-action' => 'actionUndelete' |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * Load appropriate columns based on DDS details |
378 | 378 | * @deprecated - just set the classType - either in the init or the config |
379 | 379 | */ |
380 | - public function ddsLoadGrid($classType, $includeDeleted=false, $pageSize=50) |
|
380 | + public function ddsLoadGrid($classType, $includeDeleted = false, $pageSize = 50) |
|
381 | 381 | { |
382 | 382 | if ($this->title == null) |
383 | 383 | $this->title = $classType; |
@@ -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 | |
@@ -369,8 +373,9 @@ discard block |
||
369 | 373 | 'class' => 'neon\core\grid\column\DefinitionColumn', |
370 | 374 | 'member' => new $columnType($member), |
371 | 375 | ]; |
372 | - if (is_array($config)) |
|
373 | - $colConfig = array_merge($colConfig, $config); |
|
376 | + if (is_array($config)) { |
|
377 | + $colConfig = array_merge($colConfig, $config); |
|
378 | + } |
|
374 | 379 | return $this->addColumn($member, $colConfig); |
375 | 380 | } |
376 | 381 | |
@@ -380,8 +385,9 @@ discard block |
||
380 | 385 | */ |
381 | 386 | public function ddsLoadGrid($classType, $includeDeleted=false, $pageSize=50) |
382 | 387 | { |
383 | - if ($this->title == null) |
|
384 | - $this->title = $classType; |
|
388 | + if ($this->title == null) { |
|
389 | + $this->title = $classType; |
|
390 | + } |
|
385 | 391 | // TODO: should be in constructor can't create a DDS grid without the DDS class ref |
386 | 392 | $this->classType = $classType; |
387 | 393 |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | - $paginator = [ |
|
64 | + $paginator = [ |
|
65 | 65 | 'start' => $pagination->getOffset(), |
66 | 66 | 'length' => $pagination->getLimit(), |
67 | 67 | 'total' => $pagination->totalCount |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $form = $this->getForm(); |
76 | 76 | |
77 | 77 | $data = []; |
78 | - foreach($results as $object) { |
|
78 | + foreach ($results as $object) { |
|
79 | 79 | $form->reset(); |
80 | 80 | $form->loadFromDb($object); |
81 | 81 | $data[] = array_merge($object, $form->getDataDisplay()); |
@@ -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 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | class GridAssets extends AssetBundle |
19 | 19 | { |
20 | - public $sourcePath = __DIR__ . '/assets'; |
|
20 | + public $sourcePath = __DIR__.'/assets'; |
|
21 | 21 | |
22 | 22 | public $js = [ |
23 | 23 | (YII_DEBUG ? 'neon-grid.js' : 'neon-grid.build.js'), |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param string $name |
376 | 376 | * @param callable $function |
377 | 377 | */ |
378 | - public function addScope($key, $name, $function=null) |
|
378 | + public function addScope($key, $name, $function = null) |
|
379 | 379 | { |
380 | 380 | $this->_scopes[$key] = compact('key', 'name', 'function'); |
381 | 381 | } |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $this->_filterForm = (new Form($this->getId())) |
439 | 439 | ->setId($this->getId().'Filter') |
440 | 440 | ->addSubForm('filter'); |
441 | - foreach($this->getColumns() as $key => $column) { |
|
441 | + foreach ($this->getColumns() as $key => $column) { |
|
442 | 442 | if ($column->getFilter() && $column->getFilterField() !== false) { |
443 | 443 | $field = $column->getFilterField(); |
444 | 444 | if (is_object($field)) |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | */ |
549 | 549 | public function setColumns($columns) |
550 | 550 | { |
551 | - foreach($columns as $key => $config) { |
|
551 | + foreach ($columns as $key => $config) { |
|
552 | 552 | $this->addColumn($key, $config); |
553 | 553 | } |
554 | 554 | } |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | * @throws \Exception on incorrect column config |
562 | 562 | * @return \neon\core\grid\column\Text |
563 | 563 | */ |
564 | - public function addTextColumn($key, $config=[]) |
|
564 | + public function addTextColumn($key, $config = []) |
|
565 | 565 | { |
566 | 566 | $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Text'; |
567 | 567 | return $this->addColumn($key, $config); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @throws \Exception on incorrect column config |
576 | 576 | * @return \neon\core\grid\column\Date |
577 | 577 | */ |
578 | - public function addDateColumn($key, $config=[]) |
|
578 | + public function addDateColumn($key, $config = []) |
|
579 | 579 | { |
580 | 580 | $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Date'; |
581 | 581 | return $this->addColumn($key, $config); |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | * @throws \Exception on incorrect column config |
590 | 590 | * @return \neon\core\grid\column\IntColumn |
591 | 591 | */ |
592 | - public function addIntColumn($key, $config=[]) |
|
592 | + public function addIntColumn($key, $config = []) |
|
593 | 593 | { |
594 | 594 | $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\IntColumn'; |
595 | 595 | return $this->addColumn($key, $config); |
@@ -603,9 +603,9 @@ discard block |
||
603 | 603 | * @return \neon\core\grid\column\Check |
604 | 604 | * @throws \Exception |
605 | 605 | */ |
606 | - public function addCheckColumn($key, $config=[]) |
|
606 | + public function addCheckColumn($key, $config = []) |
|
607 | 607 | { |
608 | - $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Check'; |
|
608 | + $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Check'; |
|
609 | 609 | return $this->addColumn($key, $config); |
610 | 610 | } |
611 | 611 | |
@@ -617,9 +617,9 @@ discard block |
||
617 | 617 | * @throws \Exception on incorrect column config |
618 | 618 | * @return \neon\core\grid\column\Button |
619 | 619 | */ |
620 | - public function addButtonColumn($key, $config=[]) |
|
620 | + public function addButtonColumn($key, $config = []) |
|
621 | 621 | { |
622 | - $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Button'; |
|
622 | + $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Button'; |
|
623 | 623 | return $this->addColumn($key, $config); |
624 | 624 | } |
625 | 625 | |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * @throws \Exception |
635 | 635 | * @return Column |
636 | 636 | */ |
637 | - public function addColumnFromDefinition($key, $class, $member=null, $phoebeType='daedalus') |
|
637 | + public function addColumnFromDefinition($key, $class, $member = null, $phoebeType = 'daedalus') |
|
638 | 638 | { |
639 | - static $formsDefinitionCache=[]; |
|
639 | + static $formsDefinitionCache = []; |
|
640 | 640 | $cacheKey = $class.$phoebeType; |
641 | 641 | if (!array_key_exists($cacheKey, $formsDefinitionCache)) { |
642 | 642 | $formDefinition = neon('phoebe')->getFormDefinition($phoebeType, $class); |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | * @return \neon\core\grid\column\Column |
684 | 684 | * @throws \Exception if no `$config['class']` is set |
685 | 685 | */ |
686 | - public function addColumn($key, $config=[]) |
|
686 | + public function addColumn($key, $config = []) |
|
687 | 687 | { |
688 | 688 | if (!isset($config['class'])) { |
689 | 689 | // 99% of the time you just want the standard Column class |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | */ |
746 | 746 | public function hasData() |
747 | 747 | { |
748 | - return ! empty($this->_gridData); |
|
748 | + return !empty($this->_gridData); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | /** |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | */ |
781 | 781 | public function gridBoot() |
782 | 782 | { |
783 | - if (! $this->hasData()) |
|
783 | + if (!$this->hasData()) |
|
784 | 784 | $this->_gridData = Arr::get($_REQUEST, $this->id, null); |
785 | 785 | // load the active scope |
786 | 786 | $this->_scope = Arr::get($this->_gridData, "scope", []); |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | * and true if you want the data returned as an array |
816 | 816 | * @return string | array depending on value of $asRows |
817 | 817 | */ |
818 | - public function exportCsv($page=0, $pageSize=1000, $asRows=false) |
|
818 | + public function exportCsv($page = 0, $pageSize = 1000, $asRows = false) |
|
819 | 819 | { |
820 | 820 | // check we're allowed to do this |
821 | 821 | if (!$this->canExportCsv) |
@@ -838,14 +838,14 @@ discard block |
||
838 | 838 | // Render the rows |
839 | 839 | $dataProvider = $this->getDataProvider(); |
840 | 840 | $pagination = $dataProvider->pagination; |
841 | - $pagination->page=$page; |
|
842 | - $pagination->pageSize = min(1000,$pageSize); |
|
841 | + $pagination->page = $page; |
|
842 | + $pagination->pageSize = min(1000, $pageSize); |
|
843 | 843 | $models = $dataProvider->getModels(); |
844 | 844 | if (empty($models)) |
845 | 845 | return null; |
846 | 846 | |
847 | 847 | $rows = []; |
848 | - foreach($models as $index => $row) { |
|
848 | + foreach ($models as $index => $row) { |
|
849 | 849 | $singleRow = []; |
850 | 850 | // use the columns set as not all columns exists in row data e.g. derived ones |
851 | 851 | foreach ($columns as $colKey => $column) { |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | $dataProvider->models = null; |
859 | 859 | |
860 | 860 | // Add headers columns as the first row if we are on the first page |
861 | - if ($page==0) |
|
861 | + if ($page == 0) |
|
862 | 862 | array_unshift($rows, implode(',', $headerCols)); |
863 | 863 | |
864 | 864 | return $asRows ? $rows : implode("\n", $rows); |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | public function callScope($scope, IQuery $query) |
1067 | 1067 | { |
1068 | 1068 | if ($scope['function'] == null) { |
1069 | - $func = 'scope' . ucfirst($scope['key']); |
|
1069 | + $func = 'scope'.ucfirst($scope['key']); |
|
1070 | 1070 | if ($this->hasMethod($func, false)) { |
1071 | 1071 | call_user_func(array($this, $func), $query); |
1072 | 1072 | } else { |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | public function getColumnsVisible() |
1133 | 1133 | { |
1134 | 1134 | $columns = []; |
1135 | - foreach($this->getColumns() as $key => $column) { |
|
1135 | + foreach ($this->getColumns() as $key => $column) { |
|
1136 | 1136 | if ($column->visible) |
1137 | 1137 | $columns[$key] = $column; |
1138 | 1138 | } |
@@ -1219,8 +1219,8 @@ discard block |
||
1219 | 1219 | { |
1220 | 1220 | $tags = []; |
1221 | 1221 | foreach ($row as $key => $val) { |
1222 | - if (!is_array($val)){ |
|
1223 | - $tags['{{' . $key . '}}'] = $val; |
|
1222 | + if (!is_array($val)) { |
|
1223 | + $tags['{{'.$key.'}}'] = $val; |
|
1224 | 1224 | } |
1225 | 1225 | } |
1226 | 1226 | return $tags; |
@@ -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 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - $limit = [ |
|
76 | + $limit = [ |
|
77 | 77 | 'start' => $pagination->getOffset(), |
78 | 78 | 'length' => $pagination->getLimit(), |
79 | 79 | 'total' => $pagination->totalCount |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * Store a total count to save multiple recalculations |
124 | 124 | * @var type |
125 | 125 | */ |
126 | - private $_totalCountCache=[]; |
|
126 | + private $_totalCountCache = []; |
|
127 | 127 | |
128 | 128 | /** |
129 | 129 | * @inheritDoc |
@@ -45,8 +45,9 @@ |
||
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 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function getViewPath() |
88 | 88 | { |
89 | - return __DIR__ . DIRECTORY_SEPARATOR . 'views'; |
|
89 | + return __DIR__.DIRECTORY_SEPARATOR.'views'; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | $out = '<tr>'; |
115 | - foreach($this->_grid->getColumnGroups() as $groupLabel => $details) { |
|
115 | + foreach ($this->_grid->getColumnGroups() as $groupLabel => $details) { |
|
116 | 116 | $colspan = count($details['columns']); |
117 | 117 | $out .= "<td colspan='$colspan'>$groupLabel</td>"; |
118 | 118 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | $pagination = $this->_grid->getDataProvider()->getPagination(); |
134 | 134 | $filters = []; |
135 | - foreach($this->_grid->getFilterForm()->getFields() as $field) { |
|
135 | + foreach ($this->_grid->getFilterForm()->getFields() as $field) { |
|
136 | 136 | if (!empty($field->getValue())) |
137 | 137 | $filters[$field->getInputName()] = $field->getValue(); |
138 | 138 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | { |
161 | 161 | $models = array_values($this->_grid->getDataProvider()->getModels()); |
162 | 162 | $out = ''; |
163 | - foreach($models as $index => $row) { |
|
163 | + foreach ($models as $index => $row) { |
|
164 | 164 | $out .= $this->renderRow($row); |
165 | 165 | } |
166 | 166 | return $out; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | $first = true; |
202 | 202 | $filtersHTML = ''; |
203 | - foreach($this->_grid->getScopes() as $link => $scope) { |
|
203 | + foreach ($this->_grid->getScopes() as $link => $scope) { |
|
204 | 204 | |
205 | 205 | $count = $this->_grid->getScopeTotalCount($link); |
206 | 206 | $current = ''; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $page = $pagination->getPage() + 1; |
250 | 250 | $pageCount = $pagination->pageCount; |
251 | 251 | $tagMessage = ' <b>{begin, number}-{end, number}</b> of <b>{totalCount, number}</b> {totalCount, plural, one{item} other{items}}.'; |
252 | - return Html::tag($tag, \Yii::t('yii', $tagMessage, [ |
|
252 | + return Html::tag($tag, \Yii::t('yii', $tagMessage, [ |
|
253 | 253 | 'begin' => $begin, |
254 | 254 | 'end' => $end, |
255 | 255 | 'count' => $count, |
@@ -133,13 +133,15 @@ |
||
133 | 133 | $pagination = $this->_grid->getDataProvider()->getPagination(); |
134 | 134 | $filters = []; |
135 | 135 | foreach($this->_grid->getFilterForm()->getFields() as $field) { |
136 | - if (!empty($field->getValue())) |
|
137 | - $filters[$field->getInputName()] = $field->getValue(); |
|
136 | + if (!empty($field->getValue())) { |
|
137 | + $filters[$field->getInputName()] = $field->getValue(); |
|
138 | + } |
|
138 | 139 | } |
139 | 140 | $queryParams = neon()->request->queryParams; |
140 | 141 | // remove any pre existing grid specific filters from the url - we don't want to add them twice |
141 | - if (isset($queryParams[$this->_grid->gridName()])) |
|
142 | - unset($queryParams[$this->_grid->gridName()]); |
|
142 | + if (isset($queryParams[$this->_grid->gridName()])) { |
|
143 | + unset($queryParams[$this->_grid->gridName()]); |
|
144 | + } |
|
143 | 145 | // gross - we need to remove any pre existing filters from the query params |
144 | 146 | $pagination->params = $queryParams + $filters; |
145 | 147 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * e.g. 'data' and 'deleted'. Set during construction via config. |
43 | 43 | * @var array |
44 | 44 | */ |
45 | - public $additionalColumns=[]; |
|
45 | + public $additionalColumns = []; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Default page size |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | - public function __construct($config=[]) |
|
71 | + public function __construct($config = []) |
|
72 | 72 | { |
73 | 73 | if (empty($config['phoebeType']) || empty($config['classType'])) { |
74 | 74 | throw new \RuntimeException('You need to provide at least the phoebeType and classType on construction'); |
@@ -124,8 +124,9 @@ |
||
124 | 124 | */ |
125 | 125 | public function getDataProvider() |
126 | 126 | { |
127 | - if (!$this->_dataProvider) |
|
128 | - throw new \RuntimeException('You need to call phoebeLoadGrid before the grid can be used'); |
|
127 | + if (!$this->_dataProvider) { |
|
128 | + throw new \RuntimeException('You need to call phoebeLoadGrid before the grid can be used'); |
|
129 | + } |
|
129 | 130 | return $this->_dataProvider; |
130 | 131 | } |
131 | 132 |