<?php
declare(strict_types=1);
namespace App\Nolimit\Template\Admin;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Route\RouteCollectionInterface;
use Sonata\AdminBundle\Show\ShowMapper;
final class TemplateAdmin extends AbstractAdmin
{
protected function configureDatagridFilters(DatagridMapper $filter): void
{
$filter
->add('name')
->add('comtentRo')
->add('contentHu')
->add('contentEn')
;
}
protected function configureListFields(ListMapper $list): void
{
$list
->add('id', 'number', array('label' => 'Nr.'))
->add('name')
->add(ListMapper::NAME_ACTIONS, null, [
'actions' => [
'show' => [],
'edit' => [],
//'delete' => [],
],
]);
}
protected function configureFormFields(FormMapper $form): void
{
$form
->add('name')
->add('comtentRo', CKEditorType::class)
->add('contentHu', CKEditorType::class)
->add('contentEn', CKEditorType::class)
->add('comment',CKEditorType::class)
;
}
protected function configureShowFields(ShowMapper $show): void
{
$show
->add('name')
->add('comment')
;
}
protected function configureRoutes(RouteCollectionInterface $collection): void
{
parent::configureRoutes($collection); // TODO: Change the autogenerated stub
$collection
->remove('delete')
//->remove('create')
->remove('show')
->add('delete_log', $this->getRouterIdParameter().'/delete_log');
}
protected function configureQuery(ProxyQueryInterface $query): ProxyQueryInterface
{
$query = parent::configureQuery($query);
$rootAlias = current($query->getRootAliases());
$query->andWhere(
$query->expr()->eq($rootAlias . '.deleted', ':type')
);
$query->setParameter(':type', '0');
return $query;
}
}