IMPR: code linting

This commit is contained in:
Tony Air 2022-01-13 11:54:33 +02:00
parent 6dae2f685d
commit 86a71bbb4e
2 changed files with 67 additions and 63 deletions

View File

@ -4,15 +4,15 @@
// extends global Page class
//namespace App\Pages;
use SilverStripe\CMS\Model\SiteTree;
use DNADesign\Elemental\Models\ElementContent;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\FontAwesome\FontAwesomeField;
use TractorCow\Fluent\Extension\FluentSiteTreeExtension;
class Page extends SiteTree
{
private static $default_container_class = 'container';
protected $_cached = [];
private static $default_container_class = 'container';
private static $db = [
'BlockIcon' => 'Varchar(255)',
];
@ -21,7 +21,6 @@ class Page extends SiteTree
'ElementalAreaID',
];
public static function DefaultContainer()
{
return self::config()->get('default_container_class');
@ -51,6 +50,7 @@ class Page extends SiteTree
$summary = $this->getField('Summary');
if ($summary) {
$this->_cached['summary' . $wordsToDisplay] = $summary;
return $this->_cached['summary' . $wordsToDisplay];
}
@ -61,16 +61,19 @@ class Page extends SiteTree
if ($element) {
$this->_cached['summary' . $wordsToDisplay] = $element->dbObject('HTML')->Summary($wordsToDisplay);
return $this->_cached['summary' . $wordsToDisplay];
}
$content = $this->getField('Content');
if ($content) {
$this->_cached['summary' . $wordsToDisplay] = $this->dbObject('Content')->Summary($wordsToDisplay);
return $this->_cached['summary' . $wordsToDisplay];
}
$this->_cached['summary' . $wordsToDisplay] = false;
return $this->_cached['summary' . $wordsToDisplay];
}

View File

@ -4,26 +4,26 @@
// extends global PageController class
//namespace App\Pages;
use SilverStripe\Control\Controller;
use A2nt\CMSNiceties\Templates\DeferredRequirements;
use A2nt\ElementalBasics\Models\TeamMember;
use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\Models\ElementContent;
use DNADesign\ElementalUserForms\Control\ElementFormController;
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Control\Director;
use SilverStripe\Core\Config\Config;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\View\ArrayData;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\PaginatedList;
use SilverStripe\Forms\Form;
use SilverStripe\Control\Controller;
use SilverStripe\Control\Director;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Config\Config;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\ArrayList;
use DNADesign\Elemental\Models\ElementContent;
use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\ElementalUserForms\Control\ElementFormController;
use A2nt\ElementalBasics\Models\TeamMember;
use A2nt\CMSNiceties\Templates\DeferredRequirements;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\PaginatedList;
use SilverStripe\View\ArrayData;
class PageController extends ContentController
{
@ -42,13 +42,6 @@ class PageController extends ContentController
private $site_message;
private $search_term;
protected function init()
{
DeferredRequirements::Auto();
return parent::init();
}
public function index(HTTPRequest $request)
{
$search = $request->getVar('q');
@ -66,7 +59,7 @@ class PageController extends ContentController
public function ElementalArea()
{
if (!$this->getAction() || $this->getAction() === 'index') {
if (! $this->getAction() || 'index' === $this->getAction()) {
return ElementalArea::get()->byID($this->getField('ElementalAreaID'));
}
@ -87,6 +80,7 @@ class PageController extends ContentController
public function SearchForm(): Form
{
$config = $this->SiteConfig();
return Form::create(
$this,
__FUNCTION__,
@ -117,22 +111,6 @@ class PageController extends ContentController
return $this->renderWith([__CLASS__ . '_search', 'Page']);
}
private static function getSearchObjects($classNames, $term): ArrayList
{
$elements = ArrayList::create();
foreach ($classNames as $class) {
$fields = Config::inst()->get($class, 'frontend_searchable_fields');
$find = array_combine($fields, $fields);
$find = array_map(static function () use ($term) {
return $term;
}, $find);
$elements->merge($class::get()->filterAny($find)->sort('Created DESC'));
}
return $elements;
}
public function SearchResults()
{
$term = $this->search_term;
@ -234,4 +212,27 @@ class PageController extends ContentController
{
return Director::isDev();
}
protected function init()
{
DeferredRequirements::Auto();
return parent::init();
}
private static function getSearchObjects($classNames, $term): ArrayList
{
$elements = ArrayList::create();
foreach ($classNames as $class) {
$fields = Config::inst()->get($class, 'frontend_searchable_fields');
$find = array_combine($fields, $fields);
$find = array_map(static function () use ($term) {
return $term;
}, $find);
$elements->merge($class::get()->filterAny($find)->sort('Created DESC'));
}
return $elements;
}
}