translatorAdmin = $translatorAdmin; } protected function populate(): void { if ($this->isPopulate === false) { $this->fieldList = [] ; $allFieldArray = $this->configureFields();; $this->panels = $this->configurePanels(); foreach ($this->panels as $panel) { $method = 'configureFieldsPanel' . ucfirst($panel); if (method_exists($this, $method)) { $fieldArray = $this->$method(); foreach($fieldArray as $key => $field) { if(is_string($field)) { unset($fieldArray[$key]); $fieldArray[$field] = $allFieldArray[$field]; } } $this->fieldsByPanel[$panel] = array_merge( ['panel_' . $panel => FormField::addPanel($panel)], $fieldArray ); $this->fieldList = array_merge($this->fieldList, $this->fieldsByPanel[$panel]); }else{ throw new \Exception($method . ' n\'existe pas '); } } $this->fieldList = array_merge($this->fieldList, $allFieldArray); $this->isPopulate = false; } } public function getFieldList(string $pageName = '') { $this->populate(); if($pageName == Crud::PAGE_INDEX) { $fieldArray = []; foreach($this->configureFieldsIndex() as $fieldName) { $fieldArray[] = $this->fieldList[$fieldName]; } return $fieldArray; } else { return $this->fieldList; } } public function getFieldListByPanel($panel) { $this->populate(); return $this->fieldsByPanel[$panel]; } public function getPanelList() { $this->populate(); return $this->fieldsByPanel; } public function configureFieldsPanelSeo(): array { return array( 'metaTitle' => TextField::new('metaTitle') ->setLabel('Meta Title') ->setHelp('Affiché dans les résultats de recherche Google') ->hideOnIndex(), 'metaDescription' => TextareaField::new('metaDescription') ->setLabel('Meta description') ->setHelp('Affiché dans les résultats de recherche Google') ->hideOnIndex(), 'oldUrls' => CollectionField::new('oldUrls') ->setFormTypeOption('entry_type', TextType::class) ->setLabel('Anciennes urls du document') ->hideOnIndex(), ); } public function configureFieldsPanelConf(): array { return [ //FormField::addPanel('configuration')->setTemplateName('crud/field/generic'), 'devAlias' => TextField::new('devAlias')->hideOnIndex(), ]; } }