src/AdminBundle/Admin/DCAutoSite/NewsAdmin.php line 12

Open in your IDE?
  1. <?php
  2. namespace AdminBundle\Admin\DCAutoSite;
  3. use AdminBundle\Admin\BasePostAdmin;
  4. use CoreBundle\Entity\Post;
  5. use CoreBundle\Services\Seo\AutomaticSeoGenerationAdmin;
  6. use Sonata\AdminBundle\Form\FormMapper;
  7. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  8. class NewsAdmin extends BasePostAdmin
  9. {
  10.     protected $baseRouteName 'admin_vendor_adminbundle_dc_newsadmin';
  11.     protected $baseRoutePattern 'dc-post-news';
  12.     protected AutomaticSeoGenerationAdmin $automaticSeoGenerationAdmin;
  13.     public function setExtraServices(AutomaticSeoGenerationAdmin $automaticSeoGenerationAdmin)
  14.     {
  15.         $this->automaticSeoGenerationAdmin $automaticSeoGenerationAdmin;
  16.     }
  17.     /**
  18.      * @param FormMapper $formMapper
  19.      */
  20.     protected function configureFormFields(FormMapper $formMapper): void
  21.     {
  22.         $formMapper
  23.             ->tab('Основная информация')
  24.                 ->with(' ', ['class' => 'col-lg-6 without-box-heder'])
  25.                     ->add('on_portal'CheckboxType::class, ['label' => 'Показывать на портале''required' => false])
  26.                 ->end()
  27.             ->end()
  28.         ;
  29.         parent::configureFormFields($formMapper);
  30.     }
  31.     public function preUpdate($object): void
  32.     {
  33.         $dealer $object->getDealer();
  34.         $service $this->automaticSeoGenerationAdmin;
  35.         $service->setUpFields($object,$dealer);
  36.         parent::preUpdate($object);
  37.     }
  38.     /**
  39.      * @param Post $object
  40.      */
  41.     public function postPersist($object): void
  42.     {
  43.         $dealer $object->getDealer();
  44.         $service $this->automaticSeoGenerationAdmin;
  45.         $service->setUpFields($object,$dealer);
  46.         parent::postPersist($object);
  47.     }
  48. }