mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-30 10:29:42 +00:00
FIX [duplicate] adding test and handlers to handle fusion of doublons with special cases - after codewithme session
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Actions\Remove;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
|
||||
class PersonMoveManager
|
||||
{
|
||||
public function __construct(
|
||||
/**
|
||||
* @var iterable<PersonMoveSqlHandlerInterface>
|
||||
*/
|
||||
private iterable $handlers,
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string $className
|
||||
* @param string $field
|
||||
* @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 [];
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user