mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-12 00:47:45 +00:00
Add HouseholdConverter and HouseholdParticipationConverter for audit functionality
- Implemented `HouseholdConverter` to handle `Household` entity conversions with support for associated members. - Added `HouseholdParticipationConverter` to convert `HouseholdMember` entity and retrieve linked person and household subjects. - Ensures compatibility with the audit system via `SubjectConverterInterface`.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?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\Audit\SubjectConverter;
|
||||
|
||||
use Chill\MainBundle\Audit\Subject;
|
||||
use Chill\MainBundle\Audit\SubjectBag;
|
||||
use Chill\MainBundle\Audit\SubjectConverterInterface;
|
||||
use Chill\MainBundle\Audit\SubjectConverterManagerAwareInterface;
|
||||
use Chill\MainBundle\Audit\SubjectConverterManagerAwareTrait;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
|
||||
class HouseholdConverter implements SubjectConverterInterface, SubjectConverterManagerAwareInterface
|
||||
{
|
||||
use SubjectConverterManagerAwareTrait;
|
||||
|
||||
public function convert(mixed $subject, bool $includeAssociated = false): SubjectBag
|
||||
{
|
||||
/** @var Household $subject */
|
||||
$bag = new SubjectBag(new Subject('household', ['id' => $subject->getId()]));
|
||||
|
||||
if ($includeAssociated) {
|
||||
foreach ($subject->getCurrentMembers() as $member) {
|
||||
$bag->append($this->subjectConverterManager->getSubjectsForEntity($member->getPerson()));
|
||||
}
|
||||
}
|
||||
|
||||
return $bag;
|
||||
}
|
||||
|
||||
public function supportsConvert(mixed $subject): bool
|
||||
{
|
||||
return $subject instanceof Household;
|
||||
}
|
||||
|
||||
public static function getDefaultPriority(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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\Audit\SubjectConverter;
|
||||
|
||||
use Chill\MainBundle\Audit\Subject;
|
||||
use Chill\MainBundle\Audit\SubjectBag;
|
||||
use Chill\MainBundle\Audit\SubjectConverterInterface;
|
||||
use Chill\MainBundle\Audit\SubjectConverterManagerAwareInterface;
|
||||
use Chill\MainBundle\Audit\SubjectConverterManagerAwareTrait;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
|
||||
class HouseholdParticipationConverter implements SubjectConverterInterface, SubjectConverterManagerAwareInterface
|
||||
{
|
||||
use SubjectConverterManagerAwareTrait;
|
||||
|
||||
public function convert(mixed $subject, bool $includeAssociated = false): SubjectBag
|
||||
{
|
||||
/** @var HouseholdMember $subject */
|
||||
$bag = new SubjectBag(
|
||||
new Subject('household_member', ['id' => $subject->getId()]),
|
||||
);
|
||||
|
||||
$bag->append($this->subjectConverterManager->getSubjectsForEntity($subject->getPerson()));
|
||||
$bag->append($this->subjectConverterManager->getSubjectsForEntity($subject->getHousehold()));
|
||||
|
||||
return $bag;
|
||||
}
|
||||
|
||||
public function supportsConvert(mixed $subject): bool
|
||||
{
|
||||
return $subject instanceof HouseholdMember;
|
||||
}
|
||||
|
||||
public static function getDefaultPriority(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user