Compare commits

...

33 Commits

Author SHA1 Message Date
58912f1d98 Add changie for fixes to CollectionType js 2024-08-22 14:24:58 +02:00
9604ba5f4b Merge branch 'person_resource_abstract_class' into 'upgrade-sf5'
Create abstract class for person resource and corrections made to CollectionType js

See merge request Chill-Projet/chill-bundles!716
2024-08-22 12:22:52 +00:00
b689a51a48 Changie added for fix connection to azure 2024-08-21 16:56:05 +02:00
8c0d2f58ba Add missing [ ] for schemes option 2024-08-21 16:53:26 +02:00
212230448b Add changie for fix of delete action accompanying periods 2024-08-21 15:14:48 +02:00
2bfb8fe387 Fix delete action for accompanying periods, missed in previous correction 2024-08-21 15:13:18 +02:00
6362b98a00 Specifiy https scheme for the connectAzureCheck controller method 2024-08-21 14:20:37 +02:00
6e2a08cae8 Resolve multiple entries not being saved in collectiontype 2024-08-21 10:22:13 +02:00
305105faae Fix CalendarContextTest after faulty php cs fix 2024-08-14 15:27:00 +02:00
85811cc6ae Run php-cs-fixer and rector 2024-08-14 14:45:59 +02:00
7eee995627 Merge branch 'upgrade-sf5' into person_resource_abstract_class 2024-08-14 14:26:24 +02:00
c0c448fb39 Remove dump from code 2024-08-14 14:26:04 +02:00
6445342136 Fix remove button not showing in CollectionType forms with allow_delete option 2024-08-14 14:23:03 +02:00
d52e54fd2a Make loadDynamicPicker available within windows where dynamicPicker tags are added 2024-08-14 13:38:58 +02:00
547a9d1369 Downgrade bundles to v2.23.0 fix in v2.23.1 undone 2024-08-08 11:01:21 +02:00
288a02f5b7 Undo wrong fix in export filter parcours having activity between dates
Problem reported by users, wrong analysis and fix made. Behavior was in fact
correct.
2024-08-05 15:56:40 +02:00
2f9884072c Add missing use statement for Groups annotation 2024-07-31 15:12:36 +02:00
ee45ff61a6 Reorganize person resource code to create an abstract class 2024-07-31 14:55:35 +02:00
5dfd8daf3a Remove dump causing export to fail 2024-07-30 14:58:48 +02:00
a46e987f81 Upgrade version of chill-bundles to v2.23.1 2024-07-25 16:56:43 +02:00
81220b5b22 Correct phpstan error: ParsingException is never thrown
The typing of the exception had to be changed, because \Datetime throws an \Exception
instead of a ParsingException.
2024-07-25 11:30:33 +02:00
5b0019cde7 Fix query in filter: period having activity between dates filter
Adding statement to ensure that subquery only considers records that are identical to the
ones being processed in the main query.
2024-07-25 11:23:36 +02:00
b42473b01d Upgrade bundles version with new features and fix 2024-07-23 16:54:08 +02:00
be19d09bad Fix typing error in ListActivityHelper: string expected got int 2024-07-23 16:43:54 +02:00
c82991674e Rector changes: repositories become final readonly classes 2024-07-18 09:49:05 +02:00
3fc3f32c5f Pipeline fixes 2024-07-17 16:21:19 +02:00
20af766cdf Fix the query to return the count of events
Left join was causing events to counted multiple times (once per participation). Using DISTINCT fixes this.
2024-07-17 15:38:55 +02:00
681f637d13 Merge branch 'add-module-emploi' into upgrade-sf5 2024-07-17 14:21:10 +02:00
fb8a6d960e Remove duplicate edit method in events controller 2024-07-17 14:20:15 +02:00
a2310a662f Fix delete request for event status controller 2024-07-17 14:17:19 +02:00
dd7d126bec Fix edit request for event bundle 2024-07-17 14:15:48 +02:00
29f6a43288 Fix translation in event bundle using new pluralization syntax 2024-07-17 13:35:47 +02:00
74be6460d4 Fix delete request for all entities 2024-07-17 13:33:05 +02:00
65 changed files with 368 additions and 338 deletions

View File

@@ -1,5 +0,0 @@
kind: Feature
body: '[DX] move async-upload-bundle features into chill-bundles'
time: 2023-12-12T15:48:41.954970271+01:00
custom:
Issue: "221"

View File

@@ -1,5 +0,0 @@
kind: Feature
body: Add job bundle (module emploi)
time: 2024-05-22T16:49:33.730465146+02:00
custom:
Issue: ""

View File

@@ -1,6 +0,0 @@
kind: Feature
body: |
Upgrade import of address list to the last version of compiled addresses of belgian-best-address
time: 2024-05-30T16:00:03.440767606+02:00
custom:
Issue: ""

View File

@@ -1,6 +0,0 @@
kind: Feature
body: |
Upgrade CKEditor and refactor configuration with use of typescript
time: 2024-05-31T19:02:42.776662753+02:00
custom:
Issue: ""

View File

@@ -1,6 +0,0 @@
kind: Fixed
body: Fix resolving of centers for an household, which will fix in turn the access
control
time: 2024-04-10T10:37:36.462484988+02:00
custom:
Issue: ""

View File

@@ -0,0 +1,5 @@
kind: Fixed
body: Fix delete action for accompanying periods in draft state
time: 2024-08-21T15:14:13.753383913+02:00
custom:
Issue: ""

View File

@@ -0,0 +1,5 @@
kind: Fixed
body: Fix connection to azure when making an calendar event in chill
time: 2024-08-21T16:55:37.977150909+02:00
custom:
Issue: ""

View File

@@ -0,0 +1,5 @@
kind: Fixed
body: CollectionType js fixes for remove button and adding multiple entries
time: 2024-08-22T14:24:27.381070019+02:00
custom:
Issue: ""

11
.changes/v2.23.0.md Normal file
View File

@@ -0,0 +1,11 @@
## v2.23.0 - 2024-07-23
### Feature
* ([#221](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/221)) [DX] move async-upload-bundle features into chill-bundles
* Add job bundle (module emploi)
* Upgrade import of address list to the last version of compiled addresses of belgian-best-address
* Upgrade CKEditor and refactor configuration with use of typescript
### Fixed
* Fix resolving of centers for an household, which will fix in turn the access control
* Resolved type hinting error in activity list export

View File

@@ -6,6 +6,18 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).
## v2.23.0 - 2024-07-23
### Feature
* ([#221](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/221)) [DX] move async-upload-bundle features into chill-bundles
* Add job bundle (module emploi)
* Upgrade import of address list to the last version of compiled addresses of belgian-best-address
* Upgrade CKEditor and refactor configuration with use of typescript
### Fixed
* Fix resolving of centers for an household, which will fix in turn the access control
* Resolved type hinting error in activity list export
## v2.22.2 - 2024-07-03
### Fixed
* Remove scope required for event participation stats

View File

@@ -152,7 +152,7 @@ class ListActivityHelper
return '';
}
return $this->translator->trans($value);
return $this->translator->trans((string) $value);
},
};
}

View File

@@ -73,7 +73,7 @@ final readonly class PeriodHavingActivityBetweenDatesFilter implements FilterInt
$qb->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.Activity::class." {$alias} WHERE {$alias}.date >= :{$from} AND {$alias}.date < :{$to} AND {$alias}.accompanyingPeriod = acp"
'SELECT 1 FROM '.Activity::class." {$alias} WHERE {$alias}.date >= :{$from} AND {$alias}.date < :{$to} AND {$alias}.accompanyingPeriod = activity.accompanyingPeriod"
)
);

View File

@@ -15,9 +15,9 @@ use Chill\ActivityBundle\Entity\ActivityType;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class ActivityTypeRepository implements ActivityTypeRepositoryInterface
final readonly class ActivityTypeRepository implements ActivityTypeRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $em)
{

View File

@@ -15,9 +15,9 @@ use Chill\BudgetBundle\Entity\ChargeKind;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class ChargeKindRepository implements ChargeKindRepositoryInterface
final readonly class ChargeKindRepository implements ChargeKindRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\BudgetBundle\Entity\ResourceKind;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class ResourceKindRepository implements ResourceKindRepositoryInterface
final readonly class ResourceKindRepository implements ResourceKindRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -42,7 +42,7 @@ class RemoteCalendarConnectAzureController
->redirect(['https://graph.microsoft.com/.default', 'offline_access'], []);
}
#[Route(path: '/connect/azure/check', name: 'chill_calendar_remote_connect_azure_check')]
#[Route(path: '/connect/azure/check', name: 'chill_calendar_remote_connect_azure_check', schemes: ['https'])]
public function connectAzureCheck(Request $request): Response
{
/** @var Azure $client */

View File

@@ -47,7 +47,7 @@ final class CalendarContextTest extends TestCase
{
$expected =
[
'track_datetime' => true,
'trackDatetime' => true,
'askMainPerson' => true,
'mainPersonLabel' => 'docgen.calendar.Destinee',
'askThirdParty' => false,
@@ -61,7 +61,7 @@ final class CalendarContextTest extends TestCase
{
$expected =
[
'track_datetime' => true,
'trackDatetime' => true,
'askMainPerson' => true,
'mainPersonLabel' => 'docgen.calendar.Destinee',
'askThirdParty' => false,

View File

@@ -21,14 +21,14 @@ use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
final class RelatorioDriver implements DriverInterface
final readonly class RelatorioDriver implements DriverInterface
{
private readonly string $url;
private string $url;
public function __construct(
private readonly HttpClientInterface $client,
private HttpClientInterface $client,
ParameterBagInterface $parameterBag,
private readonly LoggerInterface $logger
private LoggerInterface $logger
) {
$this->url = $parameterBag->get('chill_doc_generator')['driver']['relatorio']['url'];
}

View File

@@ -16,11 +16,11 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpFoundation\RequestStack;
final class DocGeneratorTemplateRepository implements DocGeneratorTemplateRepositoryInterface
final readonly class DocGeneratorTemplateRepository implements DocGeneratorTemplateRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager, private readonly RequestStack $requestStack)
public function __construct(EntityManagerInterface $entityManager, private RequestStack $requestStack)
{
$this->repository = $entityManager->getRepository(DocGeneratorTemplate::class);
}

View File

@@ -94,7 +94,7 @@ readonly class CountEvents implements ExportInterface, GroupedExportInterface
->leftJoin('event.participations', 'epart')
->leftJoin('epart.person', 'person');
$qb->select('COUNT(event.id) as export_count_event');
$qb->select('COUNT(DISTINCT event.id) as export_count_event');
if ($this->filterStatsByCenters) {
$qb

View File

@@ -34,7 +34,7 @@ class EventType extends AbstractType
{
$builder
->add('name', TextType::class, [
'required' => true
'required' => true,
])
->add('date', ChillDateTimeType::class, [
'required' => true,

View File

@@ -91,7 +91,7 @@ class PartenaireRomeAppellation
try {
$response = $this->httpClient->request('GET', sprintf(self::BASE.'appellation/%s', $code), [
'headers' => [
'Authorization' => 'Bearer ' . $bearer,
'Authorization' => 'Bearer '.$bearer,
'Accept' => 'application/json',
],
'query' => [
@@ -101,9 +101,9 @@ class PartenaireRomeAppellation
return $response->toArray();
} catch (HttpExceptionInterface $exception) {
if ($exception->getResponse()->getStatusCode() === 429) {
if (429 === $exception->getResponse()->getStatusCode()) {
$retryAfter = $exception->getResponse()->getHeaders(false)['retry-after'][0] ?? 1;
sleep((int)$retryAfter);
sleep((int) $retryAfter);
} else {
throw $exception;
}

View File

@@ -20,11 +20,11 @@ use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Doctrine\Persistence\ObjectRepository;
final class AddressReferenceRepository implements ObjectRepository
final readonly class AddressReferenceRepository implements ObjectRepository
{
private readonly EntityManagerInterface $entityManager;
private EntityManagerInterface $entityManager;
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -17,9 +17,9 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
final class AddressRepository implements ObjectRepository
final readonly class AddressRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\MainBundle\Entity\Center;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class CenterRepository implements CenterRepositoryInterface
final readonly class CenterRepository implements CenterRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -17,9 +17,9 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
final class CountryRepository implements ObjectRepository
final readonly class CountryRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\MainBundle\Entity\GeographicalUnitLayer;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class GeographicalUnitLayerLayerRepository implements GeographicalUnitLayerRepositoryInterface
final readonly class GeographicalUnitLayerLayerRepository implements GeographicalUnitLayerRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $em)
{

View File

@@ -18,9 +18,9 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
final class GeographicalUnitRepository implements GeographicalUnitRepositoryInterface
final readonly class GeographicalUnitRepository implements GeographicalUnitRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $em)
{

View File

@@ -16,9 +16,9 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
final class GroupCenterRepository implements ObjectRepository
final readonly class GroupCenterRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\MainBundle\Entity\Language;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class LanguageRepository implements LanguageRepositoryInterface
final readonly class LanguageRepository implements LanguageRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -16,9 +16,9 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
final class PermissionsGroupRepository implements ObjectRepository
final readonly class PermissionsGroupRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -19,11 +19,11 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
final class PostalCodeRepository implements PostalCodeRepositoryInterface
final readonly class PostalCodeRepository implements PostalCodeRepositoryInterface
{
private readonly EntityManagerInterface $entityManager;
private EntityManagerInterface $entityManager;
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -18,9 +18,9 @@ use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
use Doctrine\Persistence\ObjectRepository;
final class RegroupmentRepository implements ObjectRepository
final readonly class RegroupmentRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -16,9 +16,9 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
final class RoleScopeRepository implements ObjectRepository
final readonly class RoleScopeRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -17,11 +17,11 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
final class ScopeRepository implements ScopeRepositoryInterface
final readonly class ScopeRepository implements ScopeRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager, private readonly TranslatableStringHelperInterface $translatableStringHelper)
public function __construct(EntityManagerInterface $entityManager, private TranslatableStringHelperInterface $translatableStringHelper)
{
$this->repository = $entityManager->getRepository(Scope::class);
}

View File

@@ -53,14 +53,17 @@ export const handleAdd = (button: any): void => {
let
empty_explain: HTMLLIElement | null = collection.querySelector('li[data-collection-empty-explain]'),
entry = document.createElement('li'),
counter = collection.childNodes.length + 1,
content = prototype.replace(new RegExp('__name__', 'g'), counter.toString()),
counter = collection.querySelectorAll('li.entry').length, // Updated counter logic
content = prototype.replace(/__name__/g, counter.toString()),
event = new CustomEvent('collection-add-entry', {detail: new CollectionEventPayload(collection, entry)});
console.log(counter)
console.log(content)
entry.innerHTML = content;
entry.classList.add('entry');
if ("dataCollectionRegular" in collection.dataset) {
if ("collectionRegular" in collection.dataset) {
initializeRemove(collection, entry);
if (empty_explain !== null) {
empty_explain.remove();

View File

@@ -159,3 +159,5 @@ document.addEventListener('DOMContentLoaded', function(e) {
loadDynamicPicker(document)
})
window.loadDynamicPicker = loadDynamicPicker;

View File

@@ -32,7 +32,7 @@ abstract class AbstractSearch implements SearchInterface
{
try {
return new \DateTime($string);
} catch (ParsingException $ex) {
} catch (\Exception $ex) {
$exception = new ParsingException('The date is '
.'not parsable', 0, $ex);

View File

@@ -15,11 +15,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Contracts\Translation\TranslatorInterface;
final class TranslatableStringHelper implements TranslatableStringHelperInterface
final readonly class TranslatableStringHelper implements TranslatableStringHelperInterface
{
private readonly string $defaultLocale;
private string $defaultLocale;
public function __construct(private readonly RequestStack $requestStack, private readonly TranslatorInterface $translator, ParameterBagInterface $parameterBag)
public function __construct(private RequestStack $requestStack, private TranslatorInterface $translator, ParameterBagInterface $parameterBag)
{
$this->defaultLocale = $parameterBag->get('kernel.default_locale');
}

View File

@@ -109,11 +109,10 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle
'accompanying_period_id' => $accompanyingCourse->getId(),
'person_id' => $person_id,
]))
->setMethod('DELETE')
->add('submit', SubmitType::class, ['label' => 'Delete'])
->getForm();
if (Request::METHOD_DELETE === $request->getMethod()) {
if (Request::METHOD_POST === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {

View File

@@ -0,0 +1,198 @@
<?php
declare(strict_types=1);
/*
* 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.
*/
namespace Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\MappedSuperclass]
class AbstractPersonResource implements TrackCreationInterface, TrackUpdateInterface
{
use TrackCreationTrait;
use TrackUpdateTrait;
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'comment_')]
#[Groups(['read', 'docgen:read'])]
private CommentEmbeddable $comment;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
#[Groups(['read', 'docgen:read'])]
private ?string $freeText = null;
#[ORM\ManyToOne(targetEntity: PersonResourceKind::class, inversedBy: 'personResources')]
#[ORM\JoinColumn(nullable: true)]
#[Groups(['read', 'docgen:read'])]
private ?PersonResourceKind $kind = null;
#[ORM\ManyToOne(targetEntity: Person::class)]
#[ORM\JoinColumn(nullable: true)]
#[Groups(['read', 'docgen:read'])]
private ?Person $person = null;
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'resources')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['read'])]
private ?Person $personOwner = null;
#[ORM\ManyToOne(targetEntity: ThirdParty::class, inversedBy: 'personResources')]
#[ORM\JoinColumn(nullable: true)]
#[Groups(['read', 'docgen:read'])]
private ?ThirdParty $thirdParty = null;
public function __construct()
{
$this->comment = new CommentEmbeddable();
}
public function getComment(): CommentEmbeddable
{
return $this->comment;
}
public function getFreeText(): ?string
{
return $this->freeText;
}
public function getKind(): ?PersonResourceKind
{
return $this->kind;
}
public function getPerson(): ?Person
{
return $this->person;
}
public function getPersonOwner(): ?Person
{
return $this->personOwner;
}
/**
* @Groups({"read", "docgen:read"})
*/
public function getResourceKind(): string
{
if ($this->getPerson() instanceof Person) {
return 'person';
}
if ($this->getThirdParty() instanceof ThirdParty) {
return 'thirdparty';
}
if (null !== $this->getFreeText()) {
return 'freetext';
}
return 'none';
}
public function getThirdParty(): ?ThirdParty
{
return $this->thirdParty;
}
public function setComment(?CommentEmbeddable $comment): self
{
if (null === $comment) {
$this->comment->setComment('');
return $this;
}
$this->comment = $comment;
return $this;
}
public function setFreeText(?string $freeText): self
{
$this->freeText = $freeText;
if ('' !== $freeText && null !== $freeText) {
$this->setPerson(null);
$this->setThirdParty(null);
}
if ('' === $freeText) {
$this->freeText = 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;
}
/**
* @Assert\Callback
*/
public function validate(ExecutionContextInterface $context, mixed $payload): void
{
if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) {
$context->buildViolation('You must associate at least one entity')
->addViolation();
}
if (null !== $this->person && $this->person === $this->personOwner) {
$context->buildViolation('You cannot associate a resource with the same person')
->addViolation();
}
}
}

View File

@@ -12,206 +12,24 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['personResource' => PersonResource::class])]
#[ORM\Entity]
#[ORM\Table(name: 'chill_person_resource')]
class PersonResource implements TrackCreationInterface, TrackUpdateInterface
class PersonResource extends AbstractPersonResource implements TrackCreationInterface, TrackUpdateInterface
{
use TrackCreationTrait;
use TrackUpdateTrait;
#[Groups(['read', 'docgen:read'])]
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'comment_')]
private CommentEmbeddable $comment;
#[Groups(['read', 'docgen:read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
private ?string $freeText = null;
#[Groups(['read', 'docgen:read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
private ?int $id = null;
#[Groups(['read', 'docgen:read'])]
#[ORM\ManyToOne(targetEntity: PersonResourceKind::class, inversedBy: 'personResources')]
#[ORM\JoinColumn(nullable: true)]
private ?PersonResourceKind $kind = null;
/**
* The person which host the owner of this resource.
*/
#[Groups(['read', 'docgen:read'])]
#[ORM\ManyToOne(targetEntity: Person::class)]
#[ORM\JoinColumn(nullable: true)]
private ?Person $person = null;
/**
* The person linked with this resource.
*/
#[Groups(['read'])]
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'resources')]
#[ORM\JoinColumn(nullable: false)]
private ?Person $personOwner = null;
#[Groups(['read', 'docgen:read'])]
#[ORM\ManyToOne(targetEntity: ThirdParty::class, inversedBy: 'personResources')]
#[ORM\JoinColumn(nullable: true)]
private ?ThirdParty $thirdParty = null;
public function __construct()
{
$this->comment = new CommentEmbeddable();
}
public function getComment(): CommentEmbeddable
{
return $this->comment;
}
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;
}
#[Groups(['read', 'docgen:read'])]
public function getResourceKind(): string
{
if ($this->getPerson() instanceof Person) {
return 'person';
}
if ($this->getThirdParty() instanceof ThirdParty) {
return 'thirdparty';
}
if (null !== $this->getFreeText()) {
return 'freetext';
}
return 'none';
}
public function getThirdParty(): ?ThirdParty
{
return $this->thirdParty;
}
public function setComment(?CommentEmbeddable $comment): self
{
if (null === $comment) {
$this->comment->setComment('');
return $this;
}
$this->comment = $comment;
return $this;
}
public function setFreeText(?string $freeText): self
{
$this->freeText = $freeText;
if ('' !== $freeText && null !== $freeText) {
$this->setPerson(null);
$this->setThirdParty(null);
}
if ('' === $freeText) {
$this->freeText = 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;
}
#[Assert\Callback]
public function validate(ExecutionContextInterface $context, mixed $payload)
{
if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) {
$context->buildViolation('You must associate at least one entity')
->addViolation();
}
if (null !== $this->person && $this->person === $this->personOwner) {
$context->buildViolation('You cannot associate a resource with the same person')
->addViolation();
}
}
}

View File

@@ -20,13 +20,13 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
final class OriginAggregator implements AggregatorInterface
final readonly class OriginAggregator implements AggregatorInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(
EntityManagerInterface $em,
private readonly TranslatableStringHelper $translatableStringHelper
private TranslatableStringHelper $translatableStringHelper
) {
$this->repository = $em->getRepository(Origin::class);
}

View File

@@ -21,9 +21,9 @@ use Doctrine\ORM\EntityRepository;
* @method AccompanyingPeriodWorkGoal[] findAll()
* @method AccompanyingPeriodWorkGoal[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
final class AccompanyingPeriodWorkGoalRepository
final readonly class AccompanyingPeriodWorkGoalRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class CommentRepository
final readonly class CommentRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class OriginRepository
final readonly class OriginRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class ResourceRepository
final readonly class ResourceRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class AccompanyingPeriodParticipationRepository
final readonly class AccompanyingPeriodParticipationRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -18,9 +18,9 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
final class AccompanyingPeriodRepository implements ObjectRepository
final readonly class AccompanyingPeriodRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -16,9 +16,9 @@ use Chill\PersonBundle\Entity\Household\HouseholdComposition;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class HouseholdCompositionRepository implements HouseholdCompositionRepositoryInterface
final readonly class HouseholdCompositionRepository implements HouseholdCompositionRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\PersonBundle\Entity\Household\HouseholdCompositionType;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class HouseholdCompositionTypeRepository implements HouseholdCompositionTypeRepositoryInterface
final readonly class HouseholdCompositionTypeRepository implements HouseholdCompositionTypeRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class HouseholdMembersRepository
final readonly class HouseholdMembersRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -18,7 +18,7 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Doctrine\Persistence\ObjectRepository;
final class HouseholdRepository implements ObjectRepository
final readonly class HouseholdRepository implements ObjectRepository
{
private const SQL_BY_ACCOMPANYING_PERIOD_PARTICIPATION = <<<'SQL'
WITH participations AS (
@@ -40,9 +40,9 @@ final class HouseholdRepository implements ObjectRepository
SELECT {select} FROM households {limits}
SQL;
private readonly EntityManagerInterface $em;
private EntityManagerInterface $em;
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -16,9 +16,9 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
final class PersonHouseholdAddressRepository implements ObjectRepository
final readonly class PersonHouseholdAddressRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $em)
{

View File

@@ -18,9 +18,9 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
final class PositionRepository implements ObjectRepository
final readonly class PositionRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\PersonBundle\Entity\PersonAltName;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class PersonAltNameRepository
final readonly class PersonAltNameRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -16,9 +16,9 @@ use Chill\PersonBundle\Entity\PersonNotDuplicate;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class PersonNotDuplicateRepository
final readonly class PersonNotDuplicateRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -17,9 +17,9 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
final class PersonResourceRepository implements ObjectRepository
final readonly class PersonResourceRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -15,9 +15,9 @@ use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
final class EvaluationRepository implements EvaluationRepositoryInterface
final readonly class EvaluationRepository implements EvaluationRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -18,9 +18,9 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
final class GoalRepository implements ObjectRepository
final readonly class GoalRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -19,9 +19,9 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
final class ResultRepository implements ObjectRepository
final readonly class ResultRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -17,9 +17,9 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
final class SocialActionRepository implements ObjectRepository
final readonly class SocialActionRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -17,9 +17,9 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
final class SocialIssueRepository implements ObjectRepository
final readonly class SocialIssueRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{

View File

@@ -47,25 +47,25 @@ use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @see PersonContextTest
*/
final class PersonContext implements PersonContextInterface
final readonly class PersonContext implements PersonContextInterface
{
private readonly bool $showScopes;
private bool $showScopes;
public function __construct(
private readonly AuthorizationHelperInterface $authorizationHelper,
private readonly BaseContextData $baseContextData,
private readonly CenterResolverManagerInterface $centerResolverManager,
private readonly DocumentCategoryRepository $documentCategoryRepository,
private readonly EntityManagerInterface $em,
private readonly NormalizerInterface $normalizer,
private AuthorizationHelperInterface $authorizationHelper,
private BaseContextData $baseContextData,
private CenterResolverManagerInterface $centerResolverManager,
private DocumentCategoryRepository $documentCategoryRepository,
private EntityManagerInterface $em,
private NormalizerInterface $normalizer,
ParameterBagInterface $parameterBag,
private readonly ScopeRepositoryInterface $scopeRepository,
private readonly Security $security,
private readonly TranslatorInterface $translator,
private readonly TranslatableStringHelperInterface $translatableStringHelper,
private readonly ThirdPartyRender $thirdPartyRender,
private readonly ThirdPartyRepository $thirdPartyRepository,
private readonly ResidentialAddressRepository $residentialAddressRepository
private ScopeRepositoryInterface $scopeRepository,
private Security $security,
private TranslatorInterface $translator,
private TranslatableStringHelperInterface $translatableStringHelper,
private ThirdPartyRender $thirdPartyRender,
private ThirdPartyRepository $thirdPartyRepository,
private ResidentialAddressRepository $residentialAddressRepository
) {
$this->showScopes = $parameterBag->get('chill_main')['acl']['form_show_scopes'];
}

View File

@@ -27,18 +27,18 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Mime\MimeTypes;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
final class ChillDocumentManager implements DocumentManagerInterface
final readonly class ChillDocumentManager implements DocumentManagerInterface
{
private readonly RequestInterface $request;
private RequestInterface $request;
public function __construct(
private readonly DocumentLockManagerInterface $documentLockManager,
private readonly EntityManagerInterface $entityManager,
private DocumentLockManagerInterface $documentLockManager,
private EntityManagerInterface $entityManager,
HttpMessageFactoryInterface $httpMessageFactory,
private readonly Psr17Interface $psr17,
private Psr17Interface $psr17,
RequestStack $requestStack,
private readonly StoredObjectManagerInterface $storedObjectManager,
private readonly StoredObjectRepository $storedObjectRepository
private StoredObjectManagerInterface $storedObjectManager,
private StoredObjectRepository $storedObjectRepository
) {
$this->request = $httpMessageFactory->createRequest($requestStack->getCurrentRequest());
}