<?php
declare(strict_types=1);
namespace App\Nolimit\ProjectType\Admin;
use App\Entity\Traits\ToStringNameTrait;
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 ProjectTypeAdmin extends AbstractAdmin
{
use ToStringNameTrait;
protected function configureDatagridFilters(DatagridMapper $filter): void
{
$filter
->add('name')
;
}
protected function configureListFields(ListMapper $list): void
{
$list
->add('id', 'number', array('label' => 'Nr.'))
->addIdentifier('name')
->add(ListMapper::NAME_ACTIONS, null, [
'actions' => [
'show' => [],
'edit' => []
/*
'delete_log' => [
'template' => '/logical_delete.html.twig',
]
*/
],
]);
}
protected function configureFormFields(FormMapper $form): void
{
$form
->add('name')
->add('contentRo',CKEditorType::class)
->add('anexaRo',CKEditorType::class)
->add('contentHu',CKEditorType::class)
->add('anexaHu',CKEditorType::class)
//->add('comment',CKEditorType::class)
->add('comment',CKEditorType::class,['attr' => ['readonly' => true]])
;
}
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;
}
}