mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
35 lines
917 B
PHP
35 lines
917 B
PHP
<?php
|
|
|
|
namespace Chill\PersonBundle\Controller;
|
|
|
|
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
/**
|
|
* Controller for closing motives
|
|
*
|
|
*/
|
|
class AdminClosingMotiveController extends CRUDController
|
|
{
|
|
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;
|
|
}
|
|
}
|