cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,90 +1,73 @@
<?php
/*
* Copyright (C) 2018 Champs Libres Cooperative <info@champs-libres.coop>
*
* 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/>.
*/
namespace Chill\TaskBundle\Event\Lifecycle;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Chill\TaskBundle\Event\TaskEvent;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent;
use Symfony\Component\Workflow\Event\Event as WorkflowEvent;
/**
*
* Chill is a software for social workers
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\TaskBundle\Event\Lifecycle;
use Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent;
use Chill\TaskBundle\Event\TaskEvent;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Workflow\Event\Event as WorkflowEvent;
class TaskLifecycleEvent implements EventSubscriberInterface
{
/**
*
* @var TokenStorageInterface
*/
protected $tokenStorage;
/**
*
* @var EntityManagerInterface
*/
protected $em;
/**
* @var TokenStorageInterface
*/
protected $tokenStorage;
public function __construct(
TokenStorageInterface $tokenStorage,
TokenStorageInterface $tokenStorage,
EntityManagerInterface $em
) {
$this->tokenStorage = $tokenStorage;
$this->em = $em;
}
public static function getSubscribedEvents(): array
{
return [
TaskEvent::PERSIST => [
'onTaskPersist'
]
'onTaskPersist',
],
];
}
public function onTaskPersist(TaskEvent $e)
{
$task = $e->getTask();
$user = $this->tokenStorage->getToken()->getUser();
$event = (new SingleTaskPlaceEvent())
->setTask($task)
->setAuthor($user)
->setTransition('_creation')
->setData([
'new_states' => $task->getCurrentStates()
])
;
'new_states' => $task->getCurrentStates(),
]);
$task->getTaskPlaceEvents()->add($event);
$this->em->persist($event);
}
public function onTransition(WorkflowEvent $e)
{
$task = $e->getSubject();
$user = $this->tokenStorage->getToken()->getUser();
$event = (new SingleTaskPlaceEvent())
->setTask($task)
->setAuthor($user)
@@ -92,13 +75,11 @@ class TaskLifecycleEvent implements EventSubscriberInterface
->setData([
'old_states' => $e->getTransition()->getFroms(),
'new_states' => $e->getTransition()->getTos(),
'workflow' => $e->getWorkflowName()
])
;
'workflow' => $e->getWorkflowName(),
]);
$task->getTaskPlaceEvents()->add($event);
$this->em->persist($event);
}
}

View File

@@ -1,45 +1,31 @@
<?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\Event;
use Chill\TaskBundle\Entity\AbstractTask;
use Symfony\Component\EventDispatcher\Event;
/**
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class TaskEvent extends Event
{
const PERSIST = 'chill_task.task_persist';
public const PERSIST = 'chill_task.task_persist';
/**
*
* @var AbstractTask
*/
protected $task;
public function __construct(AbstractTask $task)
{
$this->task = $task;
}
public function getTask(): AbstractTask
{
return $this->task;
@@ -48,8 +34,7 @@ class TaskEvent extends Event
public function setTask(AbstractTask $task)
{
$this->task = $task;
return $this;
}
}

View File

@@ -1,81 +1,60 @@
<?php
/*
*
*/
namespace Chill\TaskBundle\Event\UI;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\HttpFoundation\Response;
use Chill\TaskBundle\Entity\AbstractTask;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Workflow\Transition;
/**
*
* Chill is a software for social workers
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\TaskBundle\Event\UI;
use Chill\TaskBundle\Entity\AbstractTask;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Workflow\Transition;
class UIEvent extends Event
{
const SHOW_TRANSITION_PAGE = 'chill_task.show_transition_page';
const EDIT_FORM = 'chill_task.edit_form';
const EDIT_PAGE = 'chill_task.edit_page';
public const EDIT_FORM = 'chill_task.edit_form';
public const EDIT_PAGE = 'chill_task.edit_page';
public const SHOW_TRANSITION_PAGE = 'chill_task.show_transition_page';
/**
* @var FormInterface|null
*/
protected $form;
/**
*
* @var string
*/
protected $kind;
/**
*
* @var AbstractTask
*/
protected $task;
/**
*
* @var Response|null
*/
protected $response = null;
protected $response;
/**
*
* @var FormInterface|null
* @var AbstractTask
*/
protected $form = null;
protected $task;
/**
* @var Transition
*/
protected $transition = null;
protected $transition;
public function __construct($kind, AbstractTask $task)
{
$this->kind = $kind;
$this->task = $task;
}
/**
*
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
*
* @return AbstractTask
*/
public function getTask(): AbstractTask
{
return $this->task;
}
/**
*
* @return FormInterface|null
*/
public function getForm()
@@ -83,15 +62,25 @@ class UIEvent extends Event
return $this->form;
}
public function setForm(FormInterface $form)
{
$this->form = $form;
return $this;
}
/**
*
* @return string
*/
public function getKind()
{
return $this->kind;
}
public function getResponse(): Response
{
return $this->response;
}
public function getTask(): AbstractTask
{
return $this->task;
}
/**
* @return Transition
*/
public function getTransition()
@@ -99,38 +88,32 @@ class UIEvent extends Event
return $this->transition;
}
public function setTransition(Transition $transition)
{
$this->transition = $transition;
return $this;
}
/**
*
* @return Response
*/
public function getResponse(): Response
{
return $this->response;
}
/**
*
* @param Response $response
* @return $this
*/
public function setResponse(Response $response)
{
$this->response = $response;
return $this;
}
public function hasResponse()
{
return $this->response instanceof Response;
}
public function setForm(FormInterface $form)
{
$this->form = $form;
return $this;
}
/**
* @return $this
*/
public function setResponse(Response $response)
{
$this->response = $response;
return $this;
}
public function setTransition(Transition $transition)
{
$this->transition = $transition;
return $this;
}
}