@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | |
105 | 105 | public function setQuickSearchType(string $nameOrType): SearchApi |
106 | 106 | { |
107 | - if($nameOrType === 'all') { |
|
107 | + if ($nameOrType === 'all') { |
|
108 | 108 | $this->isQuickSearch = false; |
109 | 109 | $this->quickSearchType = ''; |
110 | - } elseif($nameOrType === 'limited') { |
|
110 | + } elseif ($nameOrType === 'limited') { |
|
111 | 111 | $this->isQuickSearch = true; |
112 | 112 | $this->quickSearchType = ''; |
113 | - } elseif(class_exists($nameOrType)) { |
|
113 | + } elseif (class_exists($nameOrType)) { |
|
114 | 114 | $this->quickSearchType = $nameOrType; |
115 | 115 | $object = Injector::inst()->get($nameOrType); |
116 | 116 | $this->setIncludedClasses($object->getClassesToSearch()); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | public function setBaseClass(string $class): SearchApi |
142 | 142 | { |
143 | - if(class_exists($class)) { |
|
143 | + if (class_exists($class)) { |
|
144 | 144 | $this->baseClass = $class; |
145 | 145 | } |
146 | 146 | |
@@ -251,14 +251,14 @@ discard block |
||
251 | 251 | $count = 0; |
252 | 252 | // we should have these already. |
253 | 253 | $word = $this->securityCheckInput($word); |
254 | - if($word) { |
|
254 | + if ($word) { |
|
255 | 255 | // important to do this first |
256 | 256 | foreach ($this->objects as $item) { |
257 | 257 | $className = $item->ClassName; |
258 | 258 | if ($item->canEdit()) { |
259 | 259 | $fields = $this->getAllValidFields($className); |
260 | 260 | foreach ($fields as $field) { |
261 | - if(!$this->includeField($className, $field)) { |
|
261 | + if (!$this->includeField($className, $field)) { |
|
262 | 262 | continue; |
263 | 263 | } |
264 | 264 | $new = str_replace($word, $replace, $item->{$field}); |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | if (count($this->words)) { |
336 | 336 | foreach ($this->getAllDataObjects() as $className) { |
337 | 337 | |
338 | - if(!$this->includeClassName($className)) { |
|
338 | + if (!$this->includeClassName($className)) { |
|
339 | 339 | continue; |
340 | 340 | } |
341 | 341 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $fields = $this->getAllValidFields($className); |
344 | 344 | $filterAny = []; |
345 | 345 | foreach ($fields as $field) { |
346 | - if(!$this->includeField($className, $field)) { |
|
346 | + if (!$this->includeField($className, $field)) { |
|
347 | 347 | continue; |
348 | 348 | } |
349 | 349 | $filterAny[$field . ':PartialMatch'] = $this->words; |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $array = []; |
396 | 396 | $classNames = $this->getAllDataObjects(); |
397 | 397 | foreach ($classNames as $className) { |
398 | - if($this->includeClassName($className)) { |
|
398 | + if ($this->includeClassName($className)) { |
|
399 | 399 | $array[$className] = $className::get() |
400 | 400 | ->filter('LastEdited:GreaterThan', date('Y-m-d H:i:s', $threshold)) |
401 | 401 | ->sort(['LastEdited' => 'DESC']) |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | $items = $this->turnArrayIntoObjects($matches); |
464 | 464 | foreach ($items as $item) { |
465 | 465 | $link = $finder->getLink($item, $this->excludedClasses); |
466 | - if($item->canView()) { |
|
466 | + if ($item->canView()) { |
|
467 | 467 | $cmsEditLink = $item->canEdit() ? $finder->getCMSEditLink($item) : ''; |
468 | 468 | $list->push( |
469 | 469 | ArrayData::create( |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | } |
486 | 486 | $finder->saveCache(); |
487 | 487 | |
488 | - if(!empty($this->sortOverride)) { |
|
488 | + if (!empty($this->sortOverride)) { |
|
489 | 489 | return $list->sort($this->sortOverride); |
490 | 490 | } else { |
491 | 491 | return $list->sort(['SiteWideSearchSortValue' => 'ASC']); |
@@ -631,8 +631,8 @@ discard block |
||
631 | 631 | protected function getAllValidFields(string $className): array |
632 | 632 | { |
633 | 633 | $fields = $this->getCache()->getAllValidFields($className, $this->isQuickSearch, $this->includedFields); |
634 | - if(isset($this->includedClassFieldCombos[$className])) { |
|
635 | - foreach($this->includedClassFieldCombos[$className] as $name => $type) { |
|
634 | + if (isset($this->includedClassFieldCombos[$className])) { |
|
635 | + foreach ($this->includedClassFieldCombos[$className] as $name => $type) { |
|
636 | 636 | $fields[] = $name; |
637 | 637 | } |
638 | 638 | } |
@@ -642,13 +642,13 @@ discard block |
||
642 | 642 | |
643 | 643 | protected function includeClassName(string $className): bool |
644 | 644 | { |
645 | - if(count($this->excludedClasses) && in_array($className, $this->excludedClasses, true)) { |
|
645 | + if (count($this->excludedClasses) && in_array($className, $this->excludedClasses, true)) { |
|
646 | 646 | if ($this->debug) { |
647 | 647 | DB::alteration_message(' ... Skipping as excluded ' . $className); |
648 | 648 | } |
649 | 649 | return false; |
650 | 650 | } |
651 | - if(count($this->includedClasses) && !in_array($className, $this->includedClasses, true)) { |
|
651 | + if (count($this->includedClasses) && !in_array($className, $this->includedClasses, true)) { |
|
652 | 652 | if ($this->debug) { |
653 | 653 | DB::alteration_message(' ... Skipping as not included ' . $className); |
654 | 654 | } |
@@ -663,9 +663,9 @@ discard block |
||
663 | 663 | |
664 | 664 | protected function includeField(string $className, string $field): bool |
665 | 665 | { |
666 | - if(isset($this->includedClassFieldCombos[$className][$field])) { |
|
666 | + if (isset($this->includedClassFieldCombos[$className][$field])) { |
|
667 | 667 | return true; |
668 | - } elseif(in_array($field, $this->includedFields, true)) { |
|
668 | + } elseif (in_array($field, $this->includedFields, true)) { |
|
669 | 669 | return true; |
670 | 670 | } elseif (!in_array($field, $this->excludedFields, true)) { |
671 | 671 | return true; |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | protected function includeSubClasses(array $classes): array |
678 | 678 | { |
679 | 679 | $toAdd = []; |
680 | - foreach($classes as $class) { |
|
680 | + foreach ($classes as $class) { |
|
681 | 681 | $toAdd = array_merge($toAdd, ClassInfo::subclassesFor($class, false)); |
682 | 682 | } |
683 | 683 | return array_unique(array_merge($classes, $toAdd)); |
@@ -311,8 +311,8 @@ |
||
311 | 311 | */ |
312 | 312 | protected function classCanBeIncluded(string $dataObjectClassName): bool |
313 | 313 | { |
314 | - if(count($this->excludedClasses) || count($this->includedClasses)) { |
|
315 | - if(!class_exists($dataObjectClassName)) { |
|
314 | + if (count($this->excludedClasses) || count($this->includedClasses)) { |
|
315 | + if (!class_exists($dataObjectClassName)) { |
|
316 | 316 | return false; |
317 | 317 | } |
318 | 318 | if (count($this->includedClasses)) { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | public static function inst(string $baseClass) |
89 | 89 | { |
90 | - if(self::$singleton === null) { |
|
90 | + if (self::$singleton === null) { |
|
91 | 91 | self::$singleton = Injector::inst()->get(static::class); |
92 | 92 | } |
93 | 93 | self::$singleton->setBaseClass($baseClass); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | foreach ($this->cache['AllValidFields'][$className] as $name => $type) { |
129 | 129 | if ($this->isValidFieldType($type, $className, $name)) { |
130 | 130 | $array[] = $name; |
131 | - } elseif(in_array($name, $includedFields, true)) { |
|
131 | + } elseif (in_array($name, $includedFields, true)) { |
|
132 | 132 | $array[] = $name; |
133 | 133 | } |
134 | 134 | } |