src/AdminBundle/Admin/Founders/NewsAdmin.php line 9

Open in your IDE?
  1. <?php
  2. namespace AdminBundle\Admin\Founders;
  3. use FoundersBundle\Entity\Post;
  4. use FoundersBundle\Model\Post as ModelPost;
  5. use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
  6. class NewsAdmin extends BasePostAdmin
  7. {
  8.     protected $baseRouteName 'adminbundle_founders_news_admin';
  9.     protected $baseRoutePattern 'founders-post-news';
  10.     /**
  11.      * @param Post $object
  12.      */
  13.     public function prePersist($object): void
  14.     {
  15.         $object->setPostType(ModelPost::POST_TYPE_NEWS);
  16.         parent::prePersist($object);
  17.     }
  18.     public function configureQuery($context 'list'): ProxyQueryInterface
  19.     {
  20.         $query parent::configureQuery($context);
  21.         $query->where($query->getRootAliases()[0].'.post_type = ' ModelPost::POST_TYPE_NEWS);
  22.         return $query;
  23.     }
  24. }