mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?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\Actions\Remove;
|
|
|
|
use Chill\PersonBundle\Entity\Person;
|
|
|
|
class PersonMoveManager
|
|
{
|
|
public function __construct(
|
|
/**
|
|
* @var iterable<PersonMoveSqlHandlerInterface>
|
|
*/
|
|
private readonly iterable $handlers,
|
|
) {}
|
|
|
|
/**
|
|
* @param class-string $className
|
|
* @return bool
|
|
*/
|
|
public function hasHandler(string $className, string $field): bool
|
|
{
|
|
foreach ($this->handlers as $handler) {
|
|
if ($handler->supports($className, $field)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* @param class-string $className
|
|
* @return array<string>
|
|
*/
|
|
public function getSqls(string $className, string $field, Person $from, Person $to): array
|
|
{
|
|
foreach ($this->handlers as $handler) {
|
|
if ($handler->supports($className, $field)) {
|
|
return $handler->getSqls($className, $field, $from, $to);
|
|
}
|
|
}
|
|
return [];
|
|
}
|
|
|
|
}
|