mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* This interface must be implemented on entities which:
|
||||
* This interface must be implemented on entities which:.
|
||||
*
|
||||
* * have both social issue and is linked to an AccompanyingPeriod
|
||||
* * when the social issues in the entity should be added to the accompanying period
|
||||
|
@@ -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.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
@@ -22,37 +29,18 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListener
|
||||
$this->ensureConsistencyEntity($entity);
|
||||
}
|
||||
|
||||
public function preUpdate(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity, LifecycleEventArgs $eventArgs)
|
||||
{
|
||||
$this->ensureConsistencyEntity($entity);
|
||||
}
|
||||
|
||||
public function prePersistAccompanyingPeriod(AccompanyingPeriod $period, LifecycleEventArgs $eventArgs)
|
||||
{
|
||||
$this->ensureConsistencyAccompanyingPeriod($period);
|
||||
}
|
||||
|
||||
public function preUpdateAccompanyingPeriod(AccompanyingPeriod $period, LifecycleEventArgs $eventArgs)
|
||||
public function preUpdate(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity, LifecycleEventArgs $eventArgs)
|
||||
{
|
||||
$this->ensureConsistencyAccompanyingPeriod($period);
|
||||
$this->ensureConsistencyEntity($entity);
|
||||
}
|
||||
|
||||
private function ensureConsistencyEntity(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity): void
|
||||
public function preUpdateAccompanyingPeriod(AccompanyingPeriod $period, LifecycleEventArgs $eventArgs)
|
||||
{
|
||||
if (NULL === $period = $entity->getAccompanyingPeriod()) {
|
||||
return;
|
||||
}
|
||||
// remove issues parents on the entity itself
|
||||
$ancestors = SocialIssue::findAncestorSocialIssues($entity->getSocialIssues());
|
||||
foreach ($ancestors as $ancestor) {
|
||||
$entity->removeSocialIssue($ancestor);
|
||||
}
|
||||
|
||||
foreach ($entity->getSocialIssues() as $issue) {
|
||||
// the entity itself test if the social issue is already associated, or not
|
||||
$period->addSocialIssue($issue);
|
||||
}
|
||||
|
||||
$this->ensureConsistencyAccompanyingPeriod($period);
|
||||
}
|
||||
|
||||
@@ -64,4 +52,24 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListener
|
||||
$period->removeSocialIssue($ancestor);
|
||||
}
|
||||
}
|
||||
|
||||
private function ensureConsistencyEntity(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity): void
|
||||
{
|
||||
if (null === $period = $entity->getAccompanyingPeriod()) {
|
||||
return;
|
||||
}
|
||||
// remove issues parents on the entity itself
|
||||
$ancestors = SocialIssue::findAncestorSocialIssues($entity->getSocialIssues());
|
||||
|
||||
foreach ($ancestors as $ancestor) {
|
||||
$entity->removeSocialIssue($ancestor);
|
||||
}
|
||||
|
||||
foreach ($entity->getSocialIssues() as $issue) {
|
||||
// the entity itself test if the social issue is already associated, or not
|
||||
$period->addSocialIssue($issue);
|
||||
}
|
||||
|
||||
$this->ensureConsistencyAccompanyingPeriod($period);
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,19 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\AccompanyingPeriod\Suggestion;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
/**
|
||||
* Basic implementation: this suggestion does not return any suggestion
|
||||
* Basic implementation: this suggestion does not return any suggestion.
|
||||
*/
|
||||
final class ReferralsSuggestion implements ReferralsSuggestionInterface
|
||||
{
|
||||
@@ -16,7 +23,6 @@ final class ReferralsSuggestion implements ReferralsSuggestionInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriod $period
|
||||
* @return array|User[]
|
||||
*/
|
||||
public function findReferralSuggested(AccompanyingPeriod $period, int $limit = 50, int $start = 0): array
|
||||
|
@@ -1,12 +1,19 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\AccompanyingPeriod\Suggestion;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
/**
|
||||
* Process the suggestion of referral for a given accompanying period
|
||||
* Process the suggestion of referral for a given accompanying period.
|
||||
*/
|
||||
interface ReferralsSuggestionInterface
|
||||
{
|
||||
@@ -16,5 +23,4 @@ interface ReferralsSuggestionInterface
|
||||
* @return array|User[]
|
||||
*/
|
||||
public function findReferralSuggested(AccompanyingPeriod $period, int $limit = 50, int $start = 0): array;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user