mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
ENH: Prefer dependency injection over use of new
keyword. (#333)
* ENH: Prefer dependency injection over use of `new` keyword. * MNT Fix phpcs linting error.
This commit is contained in:
parent
8e9ee0bace
commit
8c4e924bfa
@ -96,7 +96,7 @@ class GridFieldAddExistingSearchHandler extends RequestHandler
|
||||
{
|
||||
$list = $this->context->getQuery($data, false, false, $this->getSearchList());
|
||||
$list = $list->subtract($this->grid->getList());
|
||||
$list = new PaginatedList($list, $this->request);
|
||||
$list = PaginatedList::create($list, $this->request);
|
||||
|
||||
$data = $this->customise(array(
|
||||
'SearchForm' => $form,
|
||||
@ -109,7 +109,7 @@ class GridFieldAddExistingSearchHandler extends RequestHandler
|
||||
{
|
||||
$list = $this->getSearchList();
|
||||
$list = $list->subtract($this->grid->getList());
|
||||
$list = new PaginatedList($list, $this->request);
|
||||
$list = PaginatedList::create($list, $this->request);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ class GridFieldAddNewInlineButton implements GridField_HTMLProvider, GridField_S
|
||||
Requirements::javascript('symbiote/silverstripe-gridfieldextensions:javascript/tmpl.js');
|
||||
GridFieldExtensions::include_requirements();
|
||||
|
||||
$data = new ArrayData(array(
|
||||
$data = ArrayData::create(array(
|
||||
'Title' => $this->getTitle(),
|
||||
));
|
||||
|
||||
@ -114,7 +114,7 @@ class GridFieldAddNewInlineButton implements GridField_HTMLProvider, GridField_S
|
||||
|
||||
private function getRowTemplate(GridField $grid, GridFieldEditableColumns $editable)
|
||||
{
|
||||
$columns = new ArrayList();
|
||||
$columns = ArrayList::create();
|
||||
$handled = array_keys($editable->getDisplayFields($grid));
|
||||
|
||||
if ($grid->getList()) {
|
||||
@ -161,7 +161,7 @@ class GridFieldAddNewInlineButton implements GridField_HTMLProvider, GridField_S
|
||||
$attrs .= sprintf(' %s="%s"', $attr, Convert::raw2att($val));
|
||||
}
|
||||
|
||||
$columns->push(new ArrayData(array(
|
||||
$columns->push(ArrayData::create(array(
|
||||
'Content' => $content,
|
||||
'Attributes' => DBField::create_field('HTMLFragment', $attrs),
|
||||
'IsActions' => $column == 'Actions'
|
||||
|
@ -244,13 +244,18 @@ class GridFieldAddNewMultiClass implements GridField_HTMLProvider, GridField_URL
|
||||
|
||||
GridFieldExtensions::include_requirements();
|
||||
|
||||
$field = new DropdownField(sprintf('%s[%s]', __CLASS__, $grid->getName()), '', $classes, $this->defaultClass);
|
||||
$field = DropdownField::create(
|
||||
sprintf('%s[%s]', __CLASS__, $grid->getName()),
|
||||
'',
|
||||
$classes,
|
||||
$this->defaultClass
|
||||
);
|
||||
if (Config::inst()->get(__CLASS__, 'showEmptyString')) {
|
||||
$field->setEmptyString(_t('GridFieldExtensions.SELECTTYPETOCREATE', '(Select type to create)'));
|
||||
}
|
||||
$field->addExtraClass('no-change-track');
|
||||
|
||||
$data = new ArrayData(array(
|
||||
$data = ArrayData::create(array(
|
||||
'Title' => $this->getTitle(),
|
||||
'Link' => Controller::join_links($grid->Link(), 'add-multi-class', '{class}'),
|
||||
'ClassField' => $field
|
||||
|
@ -83,7 +83,7 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
|
||||
// Fall back to previous logic
|
||||
if (!$field) {
|
||||
$rel = (strpos($col, '.') === false); // field references a relation value
|
||||
$field = ($rel) ? clone $fields->fieldByName($col) : new ReadonlyField($col);
|
||||
$field = ($rel) ? clone $fields->fieldByName($col) : ReadonlyField::create($col);
|
||||
}
|
||||
|
||||
if (!$field) {
|
||||
@ -211,7 +211,7 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
|
||||
public function getFields(GridField $grid, DataObjectInterface $record)
|
||||
{
|
||||
$cols = $this->getDisplayFields($grid);
|
||||
$fields = new FieldList();
|
||||
$fields = FieldList::create();
|
||||
|
||||
/** @var DataList $list */
|
||||
$list = $grid->getList();
|
||||
@ -263,12 +263,12 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
|
||||
if ($class && $obj = DataObject::singleton($class)->dbObject($colRelation[0])) {
|
||||
$field = $obj->scaffoldFormField();
|
||||
} else {
|
||||
$field = new ReadonlyField($colRelation[0]);
|
||||
$field = ReadonlyField::create($colRelation[0]);
|
||||
}
|
||||
} elseif ($class && $obj = DataObject::singleton($class)->dbObject($col)) {
|
||||
$field = $obj->scaffoldFormField();
|
||||
} else {
|
||||
$field = new ReadonlyField($col);
|
||||
$field = ReadonlyField::create($col);
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,7 +301,7 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
|
||||
{
|
||||
$fields = $this->getFields($grid, $record);
|
||||
|
||||
$form = new Form($grid, null, $fields, new FieldList());
|
||||
$form = Form::create($grid, null, $fields, FieldList::create());
|
||||
$form->loadDataFrom($record);
|
||||
|
||||
$form->setFormAction(Controller::join_links(
|
||||
|
@ -72,7 +72,7 @@ class GridFieldExternalLink extends GridFieldDataColumns
|
||||
*/
|
||||
public function getColumnContent($gridField, $record, $columnName)
|
||||
{
|
||||
$data = new ArrayData(array(
|
||||
$data = ArrayData::create(array(
|
||||
'Link' => $record->hasMethod('getExternalLink') ? $record->getExternalLink() : $record->ExternalLink,
|
||||
'Text' => $record->hasMethod('getExternalLinkText') ? $record->getExternalLinkText() : 'External Link'
|
||||
));
|
||||
|
@ -83,11 +83,11 @@ abstract class GridFieldRequestHandler extends RequestHandler
|
||||
*/
|
||||
public function Form()
|
||||
{
|
||||
$form = new Form(
|
||||
$form = Form::create(
|
||||
$this,
|
||||
'SilverStripe\\Forms\\Form',
|
||||
new FieldList($root = new TabSet('Root', new Tab('Main'))),
|
||||
new FieldList()
|
||||
FieldList::create($root = TabSet::create('Root', Tab::create('Main'))),
|
||||
FieldList::create()
|
||||
);
|
||||
|
||||
if ($this->getTopLevelController() instanceof LeftAndMain) {
|
||||
@ -136,7 +136,7 @@ abstract class GridFieldRequestHandler extends RequestHandler
|
||||
if ($controller->hasMethod('Breadcrumbs')) {
|
||||
return $controller->Breadcrumbs();
|
||||
} else {
|
||||
return new ArrayList();
|
||||
return ArrayList::create();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,12 @@ class GridFieldTitleHeader implements GridField_HTMLProvider
|
||||
|
||||
public function getHTMLFragments($grid)
|
||||
{
|
||||
$cols = new ArrayList();
|
||||
$cols = ArrayList::create();
|
||||
|
||||
foreach ($grid->getColumns() as $name) {
|
||||
$meta = $grid->getColumnMetadata($name);
|
||||
|
||||
$cols->push(new ArrayData(array(
|
||||
$cols->push(ArrayData::create(array(
|
||||
'Name' => $name,
|
||||
'Title' => $meta['title']
|
||||
)));
|
||||
|
Loading…
Reference in New Issue
Block a user