mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-09 16:24:59 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -16,13 +16,9 @@ use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
||||
use Chill\TaskBundle\Entity\SingleTask;
|
||||
use Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use LogicException;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
use Symfony\Component\Workflow\Workflow;
|
||||
|
||||
use function array_combine;
|
||||
use function array_map;
|
||||
|
||||
/**
|
||||
* Provide timeline elements related to tasks, in tasks context.
|
||||
*/
|
||||
@@ -49,8 +45,7 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn
|
||||
public function fetchQuery($context, $args)
|
||||
{
|
||||
if ('task' !== $context) {
|
||||
throw new LogicException(sprintf('%s is not able '
|
||||
. 'to render context %s', self::class, $context));
|
||||
throw new \LogicException(sprintf('%s is not able to render context %s', self::class, $context));
|
||||
}
|
||||
|
||||
$metadata = $this->em
|
||||
@@ -85,8 +80,8 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn
|
||||
->getRepository(SingleTaskPlaceEvent::class)
|
||||
->findBy(['id' => $ids]);
|
||||
|
||||
return array_combine(
|
||||
array_map(static fn ($e) => $e->getId(), $events),
|
||||
return \array_combine(
|
||||
\array_map(static fn ($e) => $e->getId(), $events),
|
||||
$events
|
||||
);
|
||||
}
|
||||
|
@@ -19,19 +19,9 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\TaskBundle\Entity\SingleTask;
|
||||
use Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
use Symfony\Component\Workflow\Workflow;
|
||||
use UnexpectedValueException;
|
||||
|
||||
use function array_combine;
|
||||
use function array_fill;
|
||||
use function array_map;
|
||||
use function count;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function strtr;
|
||||
|
||||
/**
|
||||
* Provide element for timeline for 'person' and 'center' context.
|
||||
@@ -47,10 +37,10 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
|
||||
$metadata = $this->em
|
||||
->getClassMetadata(SingleTaskPlaceEvent::class);
|
||||
|
||||
[ $where, $parameters ] = match ($context) {
|
||||
[$where, $parameters] = match ($context) {
|
||||
'person' => $this->getWhereClauseForPerson($args['person']),
|
||||
'center' => $this->getWhereClauseForCenter($args['centers']),
|
||||
default => throw new UnexpectedValueException("context {$context} is not supported"),
|
||||
default => throw new \UnexpectedValueException("context {$context} is not supported"),
|
||||
};
|
||||
|
||||
return TimelineSingleQuery::fromArray([
|
||||
@@ -69,8 +59,8 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
|
||||
->getRepository(SingleTaskPlaceEvent::class)
|
||||
->findBy(['id' => $ids]);
|
||||
|
||||
return array_combine(
|
||||
array_map(static fn ($e) => $e->getId(), $events),
|
||||
return \array_combine(
|
||||
\array_map(static fn ($e) => $e->getId(), $events),
|
||||
$events
|
||||
);
|
||||
}
|
||||
@@ -127,11 +117,11 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
|
||||
$taskFkPerson = $singleTask->getAssociationMapping('person')['joinColumns'][0]['name'];
|
||||
$personPk = $singleTask->getAssociationMapping('person')['joinColumns'][0]['referencedColumnName'];
|
||||
|
||||
$from = '{single_task_event} ' .
|
||||
'JOIN {single_task} ON {single_task}.{task_pk} = {single_task_event}.{event_fk_task} ' .
|
||||
$from = '{single_task_event} '.
|
||||
'JOIN {single_task} ON {single_task}.{task_pk} = {single_task_event}.{event_fk_task} '.
|
||||
'JOIN {person} ON {single_task}.{task_person_fk} = {person}.{person_pk}';
|
||||
|
||||
return strtr(
|
||||
return \strtr(
|
||||
$from,
|
||||
[
|
||||
'{single_task}' => sprintf('%s.%s', $singleTask->getSchemaName(), $singleTask->getTableName()),
|
||||
@@ -169,7 +159,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
|
||||
ActivityVoter::SEE_DETAILS
|
||||
) as $center
|
||||
) {
|
||||
if (false === in_array($center, $centers, true)) {
|
||||
if (false === \in_array($center, $centers, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -188,24 +178,24 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
|
||||
$parameters[] = $circleIds[] = $circle->getId();
|
||||
}
|
||||
|
||||
$clauses[] = strtr(
|
||||
$clauses[] = \strtr(
|
||||
$clause,
|
||||
[
|
||||
'{person}' => $person->getTableName(),
|
||||
'{center_id}' => $personFkCenter,
|
||||
'{task}' => $singleTask->getSchemaName() . '.' . $singleTask->getTableName(),
|
||||
'{task}' => $singleTask->getSchemaName().'.'.$singleTask->getTableName(),
|
||||
'{circle}' => $taskFkCircle,
|
||||
'{circle_ids}' => implode(', ', array_fill(0, count($circleIds), '?')),
|
||||
'{circle_ids}' => \implode(', ', \array_fill(0, \count($circleIds), '?')),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (0 === count($clauses)) {
|
||||
if (0 === \count($clauses)) {
|
||||
return ['FALSE = TRUE', []];
|
||||
}
|
||||
|
||||
return [
|
||||
implode(' OR ', $clauses),
|
||||
\implode(' OR ', $clauses),
|
||||
$parameters,
|
||||
];
|
||||
}
|
||||
@@ -236,7 +226,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
|
||||
$personArg->getCenter()
|
||||
);
|
||||
|
||||
if (0 === count($circles)) {
|
||||
if (0 === \count($circles)) {
|
||||
// go fast to block access to every tasks
|
||||
return ['FALSE = TRUE', []];
|
||||
}
|
||||
@@ -246,14 +236,14 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
|
||||
}
|
||||
|
||||
return [
|
||||
strtr(
|
||||
\strtr(
|
||||
$clause,
|
||||
[
|
||||
'{person}' => $person->getTableName(),
|
||||
'{person_id}' => $person->getColumnName('id'),
|
||||
'{task}' => $singleTask->getSchemaName() . '.' . $singleTask->getTableName(),
|
||||
'{task}' => $singleTask->getSchemaName().'.'.$singleTask->getTableName(),
|
||||
'{circle}' => $taskFkCircle,
|
||||
'{circle_ids}' => implode(', ', array_fill(0, count($circleIds), '?')),
|
||||
'{circle_ids}' => \implode(', ', \array_fill(0, \count($circleIds), '?')),
|
||||
]
|
||||
),
|
||||
$parameters,
|
||||
|
Reference in New Issue
Block a user