Przeglądaj źródła

Refacturing configureFields avec getPanels

feature/symfony6.1
Fab 3 lat temu
rodzic
commit
755eb83b9e
1 zmienionych plików z 13 dodań i 10 usunięć
  1. +13
    -10
      Controller/AbstractAdminController.php

+ 13
- 10
Controller/AbstractAdminController.php Wyświetl plik

@@ -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);
}
}

Ładowanie…
Anuluj
Zapisz