Quellcode durchsuchen

Refacturing configureFields avec getPanels

develop
Fab vor 3 Jahren
Ursprung
Commit
755eb83b9e
1 geänderte Dateien mit 13 neuen und 10 gelöschten Zeilen
  1. +13
    -10
      Controller/AbstractAdminController.php

+ 13
- 10
Controller/AbstractAdminController.php Datei anzeigen

@@ -168,12 +168,10 @@ abstract class AbstractAdminController extends EaAbstractCrudController
$crud->setPaginatorPageSize($maxResults);
}

public function configureFields(string $pageName): iterable
public function getSeoPanel(): ?array
{
$seoPanel = $confPanel = array();

if ($this->isInstanceOf(SeoInterface::class)) {
$seoPanel = [
return [
FormField::addPanel('seo')->setTemplateName('crud/field/generic'),
TextField::new('metaTitle')->setLabel('Meta Title')->setHelp(
'Affiché dans les résultats de recherche Google'
@@ -186,19 +184,24 @@ abstract class AbstractAdminController extends EaAbstractCrudController
'Anciennes urls du document'
)->hideOnIndex(),
];
} else {
return null;
}
}

public function getConfPanel(): ?array
{
if ($this->isInstanceOf(DevAliasInterface::class)) {
$confPanel = [
return [
FormField::addPanel('configuration')->setTemplateName('crud/field/generic'),
TextField::new('devAlias')->hideOnIndex(),
];
}else{
return null;
}

return array_merge($seoPanel, $confPanel);
}


public function sort(AdminContext $context)
{
$event = new BeforeCrudActionEvent($context);
@@ -378,12 +381,12 @@ abstract class AbstractAdminController extends EaAbstractCrudController

public function createEntity(string $entityFqcn)
{
if(method_exists($this, 'getEntityFactory')) {
if (method_exists($this, 'getEntityFactory')) {
$factoryClass = $this->getEntityFactory();
$factory = new $factoryClass;

return $factory->create();
}
else {
} else {
return parent::createEntity($entityFqcn);
}
}

Laden…
Abbrechen
Speichern