mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Chill\PersonBundle\Controller;
|
|
|
|
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
|
|
|
/**
|
|
* Class AdminClosingMotiveController
|
|
* Controller for closing motives
|
|
*
|
|
* @package Chill\PersonBundle\Controller
|
|
*/
|
|
class AdminClosingMotiveController extends CRUDController
|
|
{
|
|
|
|
/**
|
|
* @param \Chill\MainBundle\CRUD\Controller\string|string $action
|
|
* @param Request $request
|
|
* @return object
|
|
*/
|
|
protected function createEntity($action, Request $request): object
|
|
{
|
|
$entity = parent::createEntity($action, $request);
|
|
|
|
if ($request->query->has('parent_id')) {
|
|
$parentId = $request->query->getInt('parent_id');
|
|
|
|
$parent = $this->getDoctrine()->getManager()
|
|
->getRepository($this->getEntityClass())
|
|
->find($parentId);
|
|
|
|
if (NULL === $parent) {
|
|
throw $this->createNotFoundException('parent id not found');
|
|
}
|
|
|
|
$entity->setParent($parent);
|
|
}
|
|
return $entity;
|
|
}
|
|
|
|
/**
|
|
* @param string $action
|
|
* @param \Doctrine\ORM\QueryBuilder|mixed $query
|
|
* @param Request $request
|
|
* @param PaginatorInterface $paginator
|
|
* @return \Doctrine\ORM\QueryBuilder|mixed
|
|
*/
|
|
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
|
{
|
|
/** @var \Doctrine\ORM\QueryBuilder $query */
|
|
return $query->orderBy('e.ordering', 'ASC');
|
|
}
|
|
}
|