Преглед изворни кода

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…
Откажи
Сачувај