Преглед на файлове

AbstractFieldDefinition

develop
Guillaume преди 3 години
родител
ревизия
e30c40a6e1
променени са 1 файла, в които са добавени 18 реда и са изтрити 4 реда
  1. +18
    -4
      Definition/Field/AbstractFieldDefinition.php

+ 18
- 4
Definition/Field/AbstractFieldDefinition.php Целия файл

@@ -4,9 +4,11 @@ namespace Lc\SovBundle\Definition\Field;

use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Field\CollectionField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Translation\TranslatorAdmin;
use PhpParser\Node\Expr\Throw_;
use Symfony\Component\Form\Extension\Core\Type\TextType;
@@ -25,6 +27,7 @@ abstract class AbstractFieldDefinition
public function configureFieldsBase(): array
{
return [
'id' => IntegerField::new('id')->onlyOnIndex()->setSortable(true),
'metaTitle' => TextField::new('metaTitle')
->setLabel('Meta Title')
->setHelp('Affiché dans les résultats de recherche Google')
@@ -38,6 +41,7 @@ abstract class AbstractFieldDefinition
->setLabel('Anciennes urls du document')
->hideOnIndex(),
'devAlias' => TextField::new('devAlias')->hideOnIndex(),
'status' => StatusField::new('status')->setSortable(true),
];
}

@@ -105,19 +109,29 @@ abstract class AbstractFieldDefinition
);
}

public function buildFieldArray(array $configureFieldArray): array
public function getFieldsByPanel(string $panel): array
{
return $this->buildFieldArrayFormByPanel($panel);
}

protected function buildFieldArray(array $configureFieldArray): array
{
$allFieldArray = $this->getAllFields();

$fieldArray = [];
foreach($configureFieldArray as $fieldName) {
$fieldArray[] = $allFieldArray[$fieldName];
if(isset($allFieldArray[$fieldName])) {
$fieldArray[] = $allFieldArray[$fieldName];
}
else {
throw new \ErrorException('Le field "'.$fieldName.'" n\'est pas défini dans configureFields()');
}
}

return $fieldArray;
}

public function buildFieldArrayForm(): array
protected function buildFieldArrayForm(): array
{
$fieldArray = [];
$panelArray = $this->configurePanels();
@@ -137,7 +151,7 @@ abstract class AbstractFieldDefinition
return $fieldArray;
}

public function buildFieldArrayFormByPanel(string $panel): array
protected function buildFieldArrayFormByPanel(string $panel): array
{
$method = 'configurePanel' . ucfirst($panel);
if(method_exists($this, $method)) {

Loading…
Отказ
Запис