mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
CSfixer changes
This commit is contained in:
parent
8c27ec0720
commit
f27dca6fb5
@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\ActivityBundle\Entity;
|
||||
|
||||
use Chill\ActivityBundle\Validator\Constraints as ActivityValidator;
|
||||
use Chill\DocStoreBundle\Entity\Document;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
|
@ -24,7 +24,6 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
@ -33,8 +32,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use function array_key_exists;
|
||||
|
||||
class ActivityContext implements
|
||||
DocGeneratorContextWithAdminFormInterface,
|
||||
DocGeneratorContextWithPublicFormInterface
|
||||
|
@ -16,7 +16,6 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException as ExceptionUnexpectedValueException;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
@ -59,7 +58,7 @@ class EntityToJsonTransformer implements DataTransformerInterface
|
||||
);
|
||||
}
|
||||
|
||||
if ($value === '') {
|
||||
if ('' === $value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -93,15 +92,21 @@ class EntityToJsonTransformer implements DataTransformerInterface
|
||||
switch ($this->type) {
|
||||
case 'user':
|
||||
$class = User::class;
|
||||
|
||||
break;
|
||||
|
||||
case 'person':
|
||||
$class = Person::class;
|
||||
|
||||
break;
|
||||
|
||||
case 'thirdparty':
|
||||
$class = ThirdParty::class;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \UnexpectedValueException('This type is not supported');
|
||||
throw new UnexpectedValueException('This type is not supported');
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -25,9 +25,12 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class PersonResourceController extends AbstractController
|
||||
{
|
||||
private PersonResourceRepository $personResourceRepository;
|
||||
private PersonRepository $personRepository;
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private PersonRepository $personRepository;
|
||||
|
||||
private PersonResourceRepository $personResourceRepository;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(
|
||||
@ -35,14 +38,95 @@ final class PersonResourceController extends AbstractController
|
||||
PersonRepository $personRepository,
|
||||
EntityManagerInterface $em,
|
||||
TranslatorInterface $translator
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->personResourceRepository = $personResourceRepository;
|
||||
$this->personRepository = $personRepository;
|
||||
$this->em = $em;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function deleteAction(Request $request, $person_id, $resource_id): Response
|
||||
{
|
||||
$personOwner = $this->personRepository->find($person_id);
|
||||
$resource = $this->personResourceRepository->find($resource_id);
|
||||
|
||||
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $personOwner);
|
||||
|
||||
if (null === $resource) {
|
||||
throw $this->createNotFoundException('Unable to find Resource entity.');
|
||||
}
|
||||
|
||||
$form = $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('chill_person_resource_delete', [
|
||||
'resource_id' => $resource_id,
|
||||
'person_id' => $person_id,
|
||||
]))
|
||||
->setMethod('DELETE')
|
||||
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||
->getForm();
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
$this->em->remove($resource);
|
||||
$this->em->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans('The resource has been successfully removed.'));
|
||||
|
||||
return $this->redirectToRoute('chill_person_resource_list', [
|
||||
'person_id' => $personOwner->getId(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'ChillPersonBundle:PersonResource:delete.html.twig',
|
||||
[
|
||||
'person' => $personOwner,
|
||||
'resource' => $resource,
|
||||
'form' => $form->createView(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function editAction(Request $request, $resource_id, $person_id): Response
|
||||
{
|
||||
$resource = $this->personResourceRepository->find($resource_id);
|
||||
$personOwner = $this->personRepository->find($person_id);
|
||||
|
||||
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $personOwner);
|
||||
|
||||
if (null === $resource) {
|
||||
throw $this->createNotFoundException('Unable to find Resource entity.');
|
||||
}
|
||||
|
||||
$form = $this->createForm(PersonResourceType::class, $resource);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->em->persist($resource);
|
||||
$this->em->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_person_resource_list', [
|
||||
'person_id' => $personOwner->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
dump($resource);
|
||||
|
||||
return $this->render(
|
||||
'ChillPersonBundle:PersonResource:edit.html.twig',
|
||||
[
|
||||
'person' => $personOwner,
|
||||
'resource' => $resource,
|
||||
'form' => $form->createView(),
|
||||
'action' => 'edit',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function listAction(Request $request, $person_id)
|
||||
{
|
||||
$personOwner = $this->personRepository->find($person_id);
|
||||
@ -56,7 +140,6 @@ final class PersonResourceController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_POST && $form->isValid()) {
|
||||
|
||||
$this->denyAccessUnlessGranted(PersonVoter::CREATE, $personOwner);
|
||||
|
||||
$personResource = new PersonResource();
|
||||
@ -81,7 +164,6 @@ final class PersonResourceController extends AbstractController
|
||||
return $this->redirectToRoute('chill_person_resource_list', [
|
||||
'person_id' => $personOwner->getId(),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
@ -89,91 +171,8 @@ final class PersonResourceController extends AbstractController
|
||||
[
|
||||
'person' => $personOwner,
|
||||
'personResources' => $personResources,
|
||||
'form' => $form->createView()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function editAction(Request $request, $resource_id, $person_id): Response
|
||||
{
|
||||
$resource = $this->personResourceRepository->find($resource_id);
|
||||
$personOwner = $this->personRepository->find($person_id);
|
||||
|
||||
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $personOwner);
|
||||
|
||||
if (null === $resource) {
|
||||
throw $this->createNotFoundException('Unable to find Resource entity.');
|
||||
}
|
||||
|
||||
$form = $this->createForm(PersonResourceType::class, $resource);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if($form->isSubmitted() && $form->isValid()) {
|
||||
$this->em->persist($resource);
|
||||
$this->em->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_person_resource_list', [
|
||||
'person_id' => $personOwner->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
dump($resource);
|
||||
|
||||
return $this->render(
|
||||
'ChillPersonBundle:PersonResource:edit.html.twig',
|
||||
[
|
||||
'person' => $personOwner,
|
||||
'resource' => $resource,
|
||||
'form' => $form->createView(),
|
||||
'action' => 'edit'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function deleteAction(Request $request, $person_id, $resource_id): Response
|
||||
{
|
||||
|
||||
$personOwner = $this->personRepository->find($person_id);
|
||||
$resource = $this->personResourceRepository->find($resource_id);
|
||||
|
||||
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $personOwner);
|
||||
|
||||
if (null === $resource) {
|
||||
throw $this->createNotFoundException('Unable to find Resource entity.');
|
||||
}
|
||||
|
||||
$form = $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('chill_person_resource_delete', [
|
||||
'resource_id' => $resource_id,
|
||||
'person_id' => $person_id,
|
||||
]))
|
||||
->setMethod('DELETE')
|
||||
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||
->getForm();
|
||||
|
||||
if($request->getMethod() === Request::METHOD_DELETE) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
$this->em->remove($resource);
|
||||
$this->em->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans('The resource has been successfully removed.'));
|
||||
|
||||
return $this->redirectToRoute('chill_person_resource_list', [
|
||||
'person_id' => $personOwner->getId(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'ChillPersonBundle:PersonResource:delete.html.twig',
|
||||
[
|
||||
'person' => $personOwner,
|
||||
'resource' => $resource,
|
||||
'form' => $form->createView()
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ class AccompanyingPeriod implements
|
||||
return [[self::STEP_DRAFT, self::STEP_CONFIRMED]];
|
||||
}
|
||||
|
||||
throw new LogicException('no validation group permitted with this step: '.$this->getStep());
|
||||
throw new LogicException('no validation group permitted with this step: ' . $this->getStep());
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
|
@ -32,53 +32,12 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
*/
|
||||
class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private ?int $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private ?Person $personOwner = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="personResources")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class, inversedBy="personResources")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private ?ThirdParty $thirdParty = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $freeText;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private CommentEmbeddable $comment;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=PersonResourceKind::class, inversedBy="personResources")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $kind;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
@ -90,6 +49,47 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
*/
|
||||
private User $createdBy;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $freeText;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private ?int $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=PersonResourceKind::class, inversedBy="personResources")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $kind;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="personResources")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private ?Person $personOwner = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class, inversedBy="personResources")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private ?ThirdParty $thirdParty = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
@ -105,45 +105,11 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
$this->comment = new CommentEmbeddable();
|
||||
}
|
||||
|
||||
/**
|
||||
* GETTERS
|
||||
*/
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getFreeText(): ?string
|
||||
{
|
||||
return $this->freeText;
|
||||
}
|
||||
|
||||
public function getComment(): CommentEmbeddable
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function getKind(): ?PersonResourceKind
|
||||
{
|
||||
return $this->kind;
|
||||
}
|
||||
|
||||
public function getPersonOwner(): ?Person
|
||||
{
|
||||
return $this->personOwner;
|
||||
}
|
||||
|
||||
public function getPerson(): ?Person
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
public function getThirdParty(): ?ThirdParty
|
||||
{
|
||||
return $this->thirdParty;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?DateTimeInterface
|
||||
{
|
||||
return $this->createdAt;
|
||||
@ -154,6 +120,39 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function getFreeText(): ?string
|
||||
{
|
||||
return $this->freeText;
|
||||
}
|
||||
|
||||
/**
|
||||
* GETTERS.
|
||||
*/
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getKind(): ?PersonResourceKind
|
||||
{
|
||||
return $this->kind;
|
||||
}
|
||||
|
||||
public function getPerson(): ?Person
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
public function getPersonOwner(): ?Person
|
||||
{
|
||||
return $this->personOwner;
|
||||
}
|
||||
|
||||
public function getThirdParty(): ?ThirdParty
|
||||
{
|
||||
return $this->thirdParty;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
@ -164,26 +163,11 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* SETTERS
|
||||
*/
|
||||
|
||||
public function setFreeText(?string $freeText): self
|
||||
{
|
||||
$this->freeText = $freeText;
|
||||
|
||||
if ('' !== $freeText && $freeText !== null) {
|
||||
$this->setPerson(null);
|
||||
$this->setThirdParty(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setComment(?CommentEmbeddable $comment): self
|
||||
{
|
||||
if ($comment === null) {
|
||||
if (null === $comment) {
|
||||
$this->comment->setComment('');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -192,44 +176,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setKind(?PersonResourceKind $kind): self
|
||||
{
|
||||
$this->kind = $kind;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPersonOwner(?Person $personOwner): self
|
||||
{
|
||||
$this->personOwner = $personOwner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPerson(?Person $person): self
|
||||
{
|
||||
$this->person = $person;
|
||||
|
||||
if (null !== $person) {
|
||||
$this->setFreeText("");
|
||||
$this->setThirdParty(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setThirdParty(?ThirdParty $thirdParty): self
|
||||
{
|
||||
$this->thirdParty = $thirdParty;
|
||||
|
||||
if (null !== $thirdParty) {
|
||||
$this->setFreeText("");
|
||||
$this->setPerson(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedAt(DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
@ -244,6 +190,59 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* SETTERS.
|
||||
*/
|
||||
public function setFreeText(?string $freeText): self
|
||||
{
|
||||
$this->freeText = $freeText;
|
||||
|
||||
if ('' !== $freeText && null !== $freeText) {
|
||||
$this->setPerson(null);
|
||||
$this->setThirdParty(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setKind(?PersonResourceKind $kind): self
|
||||
{
|
||||
$this->kind = $kind;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPerson(?Person $person): self
|
||||
{
|
||||
$this->person = $person;
|
||||
|
||||
if (null !== $person) {
|
||||
$this->setFreeText('');
|
||||
$this->setThirdParty(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPersonOwner(?Person $personOwner): self
|
||||
{
|
||||
$this->personOwner = $personOwner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setThirdParty(?ThirdParty $thirdParty): self
|
||||
{
|
||||
$this->thirdParty = $thirdParty;
|
||||
|
||||
if (null !== $thirdParty) {
|
||||
$this->setFreeText('');
|
||||
$this->setPerson(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
@ -257,5 +256,4 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,16 +28,16 @@ class PersonResourceKind
|
||||
*/
|
||||
private int $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", length=255)
|
||||
*/
|
||||
private array $title;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private bool $isActive = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", length=255)
|
||||
*/
|
||||
private array $title;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@ -53,17 +53,17 @@ class PersonResourceKind
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setIsActive(bool $isActive): self
|
||||
{
|
||||
$this->isActive = $isActive;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -11,32 +11,30 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Form;
|
||||
|
||||
use Chill\AsideActivityBundle\Templating\Entity\CategoryRender;
|
||||
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||
use Chill\MainBundle\Form\Type\CommentType;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Person\PersonResource;
|
||||
use Chill\PersonBundle\Entity\Person\PersonResourceKind;
|
||||
use Chill\PersonBundle\Form\Type\PickPersonDynamicType;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
||||
use Chill\PersonBundle\Templating\Entity\ResourceKindRender;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
|
||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RadioType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class PersonResourceType extends AbstractType
|
||||
{
|
||||
private ResourceKindRender $resourceKindRender;
|
||||
private PersonRender $personRender;
|
||||
|
||||
private ResourceKindRender $resourceKindRender;
|
||||
|
||||
private ThirdPartyRender $thirdPartyRender;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(ResourceKindRender $resourceKindRender, PersonRender $personRender, ThirdPartyRender $thirdPartyRender, TranslatorInterface $translator)
|
||||
@ -57,13 +55,15 @@ final class PersonResourceType extends AbstractType
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
$qb = $er->createQueryBuilder('pr');
|
||||
$qb->where($qb->expr()->eq('pr.isActive', 'TRUE'));
|
||||
|
||||
return $qb;
|
||||
},
|
||||
'placeholder' => $this->translator->trans('Select a type'),
|
||||
'choice_label' => function (PersonResourceKind $personResourceKind) {
|
||||
$options = [];
|
||||
|
||||
return $this->resourceKindRender->renderString($personResourceKind, $options);
|
||||
}
|
||||
},
|
||||
])
|
||||
->add('person', PickPersonDynamicType::class, [
|
||||
'label' => 'Usager',
|
||||
@ -73,11 +73,11 @@ final class PersonResourceType extends AbstractType
|
||||
])
|
||||
->add('freetext', ChillTextareaType::class, [
|
||||
'label' => 'Description libre',
|
||||
'required' => false
|
||||
'required' => false,
|
||||
])
|
||||
->add('comment', CommentType::class, [
|
||||
'label' => 'Note',
|
||||
'required' => false
|
||||
'required' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -92,5 +92,4 @@ final class PersonResourceType extends AbstractType
|
||||
{
|
||||
return 'chill_personbundle_person_resource';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -103,9 +103,9 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
'person_id' => $parameters['person']->getId(),
|
||||
],
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 99999,
|
||||
]);
|
||||
->setExtras([
|
||||
'order' => 99999,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
|
@ -58,4 +58,4 @@ final class PersonResourceRepository implements ObjectRepository
|
||||
{
|
||||
return PersonResource::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,7 @@ final class ResourceKindRender implements ChillEntityRenderInterface
|
||||
$title = '';
|
||||
|
||||
if (null !== $entity->getTitle()) {
|
||||
$title = $this->translatableStringHelper->localize($entity->getTitle());
|
||||
return $title;
|
||||
return $this->translatableStringHelper->localize($entity->getTitle());
|
||||
}
|
||||
|
||||
return $title;
|
||||
@ -50,5 +49,4 @@ final class ResourceKindRender implements ChillEntityRenderInterface
|
||||
{
|
||||
return $entity instanceof PersonResourceKind;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@ -8,10 +15,18 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Creation of person resource and person resource kind
|
||||
* Creation of person resource and person resource kind.
|
||||
*/
|
||||
final class Version20220119155944 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SEQUENCE chill_person_resource_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_resource_kind_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_resource');
|
||||
$this->addSql('DROP TABLE chill_person_resource_kind');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Creation of person resource and person resource kind';
|
||||
@ -36,12 +51,4 @@ final class Version20220119155944 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D923174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D9265FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SEQUENCE chill_person_resource_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_resource_kind_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_resource');
|
||||
$this->addSql('DROP TABLE chill_person_resource_kind');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user