mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-07 15:25:00 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,50 +1,42 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2018 Champs Libres Cooperative <info@champs-libres.coop>
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\TaskBundle\Timeline;
|
||||
|
||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||
use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent;
|
||||
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
|
||||
*
|
||||
* Provide timeline elements related to tasks, in tasks context.
|
||||
*/
|
||||
class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
|
||||
{
|
||||
public const TYPE = 'chill_task.transition';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
protected $em;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
protected $registry;
|
||||
|
||||
const TYPE = 'chill_task.transition';
|
||||
|
||||
public function __construct(EntityManagerInterface $em, Registry $registry)
|
||||
{
|
||||
$this->em = $em;
|
||||
@@ -53,8 +45,8 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn
|
||||
|
||||
public function fetchQuery($context, $args)
|
||||
{
|
||||
if ($context !== 'task') {
|
||||
throw new \LogicException(sprintf('%s is not able '
|
||||
if ('task' !== $context) {
|
||||
throw new LogicException(sprintf('%s is not able '
|
||||
. 'to render context %s', self::class, $context));
|
||||
}
|
||||
|
||||
@@ -67,33 +59,33 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn
|
||||
'id' => sprintf('%s.%s.%s', $metadata->getSchemaName(), $metadata->getTableName(), $metadata->getColumnName('id')),
|
||||
'type' => self::TYPE,
|
||||
'date' => $metadata->getColumnName('datetime'),
|
||||
'FROM' => sprintf('%s JOIN %s ON %s = %s',
|
||||
'FROM' => sprintf(
|
||||
'%s JOIN %s ON %s = %s',
|
||||
sprintf('%s.%s', $metadata->getSchemaName(), $metadata->getTableName()),
|
||||
sprintf('%s.%s', $singleTaskMetadata->getSchemaName(), $singleTaskMetadata->getTableName()),
|
||||
$metadata->getAssociationMapping('task')['joinColumns'][0]['name'],
|
||||
sprintf('%s.%s.%s', $singleTaskMetadata->getSchemaName(), $singleTaskMetadata->getTableName(), $singleTaskMetadata->getColumnName('id'))
|
||||
),
|
||||
'WHERE' => sprintf('%s.%s = %d',
|
||||
),
|
||||
'WHERE' => sprintf(
|
||||
'%s.%s = %d',
|
||||
sprintf('%s.%s', $singleTaskMetadata->getSchemaName(), $singleTaskMetadata->getTableName()),
|
||||
$singleTaskMetadata->getColumnName('id'),
|
||||
$args['task']->getId()
|
||||
),
|
||||
),
|
||||
'parameters' => [],
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function getEntities(array $ids)
|
||||
{
|
||||
$events = $this->em
|
||||
->getRepository(SingleTaskPlaceEvent::class)
|
||||
->findBy([ 'id' => $ids ])
|
||||
;
|
||||
->findBy(['id' => $ids]);
|
||||
|
||||
return \array_combine(
|
||||
\array_map(function($e) { return $e->getId(); }, $events ),
|
||||
return array_combine(
|
||||
array_map(function ($e) { return $e->getId(); }, $events),
|
||||
$events
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
public function getEntityTemplate($entity, $context, array $args)
|
||||
@@ -102,21 +94,25 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn
|
||||
$workflow = $this->registry->get($entity->getTask(), $entity->getData()['workflow']);
|
||||
$transition = $this->getTransitionByName($entity->getTransition(), $workflow);
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'template' => 'ChillTaskBundle:Timeline:single_task_transition_task_context.html.twig',
|
||||
'template_data' => [
|
||||
'task' => $args['task'],
|
||||
'event' => $entity,
|
||||
'transition' => $transition ?? null
|
||||
]
|
||||
'transition' => $transition ?? null,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function supportsType($type): bool
|
||||
{
|
||||
return self::TYPE === $type;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $name
|
||||
* @param Workflow $workflow
|
||||
*
|
||||
* @return \Symfony\Component\Workflow\Transition
|
||||
*/
|
||||
protected function getTransitionByName($name, Workflow $workflow)
|
||||
@@ -127,9 +123,4 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function supportsType($type): bool
|
||||
{
|
||||
return $type === self::TYPE;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user