Browse Source

Refacturing configureFields avec getPanels

develop
Fab 3 years ago
parent
commit
755eb83b9e
1 changed files with 13 additions and 10 deletions
  1. +13
    -10
      Controller/AbstractAdminController.php

+ 13
- 10
Controller/AbstractAdminController.php View File

$crud->setPaginatorPageSize($maxResults); $crud->setPaginatorPageSize($maxResults);
} }


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

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


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


return array_merge($seoPanel, $confPanel);
} }



public function sort(AdminContext $context) public function sort(AdminContext $context)
{ {
$event = new BeforeCrudActionEvent($context); $event = new BeforeCrudActionEvent($context);


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

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

Loading…
Cancel
Save