<?php
namespace AdminBundle\Admin\Founders;
use FoundersBundle\Entity\Post;
use FoundersBundle\Model\Post as ModelPost;
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
class NewsAdmin extends BasePostAdmin
{
protected $baseRouteName = 'adminbundle_founders_news_admin';
protected $baseRoutePattern = 'founders-post-news';
/**
* @param Post $object
*/
public function prePersist($object): void
{
$object->setPostType(ModelPost::POST_TYPE_NEWS);
parent::prePersist($object);
}
public function configureQuery($context = 'list'): ProxyQueryInterface
{
$query = parent::configureQuery($context);
$query->where($query->getRootAliases()[0].'.post_type = ' . ModelPost::POST_TYPE_NEWS);
return $query;
}
}