소스 검색

Refacturing configureFields avec getPanels

develop
Fab 3 년 전
부모
커밋
755eb83b9e
1개의 변경된 파일13개의 추가작업 그리고 10개의 파일을 삭제
  1. +13
    -10
      Controller/AbstractAdminController.php

+ 13
- 10
Controller/AbstractAdminController.php 파일 보기

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

Loading…
취소
저장