Merge branch 'sf4' of framagit.org:Chill-project/Chill-Task into sf4

This commit is contained in:
Tchama 2020-09-08 11:32:41 +02:00
commit 20807f637d
39 changed files with 98 additions and 74 deletions

View File

@ -4,7 +4,7 @@ namespace Chill\TaskBundle\Controller;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
use Doctrine\ORM\EntityManager;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\HttpFoundation\Request;
@ -27,6 +27,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Chill\TaskBundle\Event\UI\UIEvent;
use Chill\MainBundle\Repository\CenterRepository;
use Chill\MainBundle\Timeline\TimelineBuilder;
class SingleTaskController extends Controller
@ -37,14 +38,23 @@ class SingleTaskController extends Controller
*/
protected $eventDispatcher;
/**
*
* @var TimelineBuilder
*/
protected $timelineBuilder;
/**
* SingleTaskController constructor.
*
* @param EventDispatcherInterface $eventDispatcher
*/
public function __construct(EventDispatcherInterface $eventDispatcher)
{
public function __construct(
EventDispatcherInterface $eventDispatcher,
TimelineBuilder $timelineBuilder
) {
$this->eventDispatcher = $eventDispatcher;
$this->timelineBuilder = $timelineBuilder;
}
@ -65,7 +75,9 @@ class SingleTaskController extends Controller
;
if ($request->query->has('person_id')) {
$personId = $request->query->getInt('person_id', null);
$personId = $request->query->getInt('person_id', 0); // sf4 check:
// prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given`
if ($personId === null) {
return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST);
@ -151,7 +163,7 @@ class SingleTaskController extends Controller
throw $this->createNotFoundException('Unable to find Task entity.');
}
$timeline = $this->get('chill.main.timeline_builder')
$timeline = $this->timelineBuilder
->getTimelineHTML('task', array('task' => $task));
$event = new PrivacyEvent($person, array(
@ -444,7 +456,9 @@ class SingleTaskController extends Controller
if ($request->query->get('user_id') === '_unassigned') {
$params['unassigned'] = true;
} else {
$userId = $request->query->getInt('user_id', null);
$userId = $request->query->getInt('user_id', 0); // sf4 check:
// prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given`
$user = $this->getDoctrine()->getManager()
->getRepository('ChillMainBundle:User')
->find($userId);
@ -460,7 +474,9 @@ class SingleTaskController extends Controller
if (!empty($request->query->get('scope_id'))) {
$scopeId = $request->query->getInt('scope_id', null);
$scopeId = $request->query->getInt('scope_id', 0); // sf4 check:
// prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given`
$scope = $this->getDoctrine()->getManager()
->getRepository('ChillMainBundle:Scope')
->find($scopeId);
@ -527,7 +543,7 @@ class SingleTaskController extends Controller
if ($viewParams['person'] !== null){
$viewParams['layout'] = 'ChillPersonBundle::layout.html.twig';
} else {
$viewParams['layout'] = 'ChillMainBundle::layout.html.twig';
$viewParams['layout'] = '@ChillMain/layout.html.twig';
}
// Form for filtering tasks

View File

@ -21,7 +21,7 @@ namespace Chill\TaskBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;

View File

@ -25,17 +25,17 @@ class ChillTaskExtension extends Extension implements PrependExtensionInterface
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services/controller.yml');
$loader->load('services/security.yml');
$loader->load('services/repositories.yml');
$loader->load('services/workflow.yml');
$loader->load('services/templating.yml');
$loader->load('services/menu.yml');
$loader->load('services/event.yml');
$loader->load('services/timeline.yml');
$loader->load('services/fixtures.yml');
$loader->load('services/form.yml');
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
$loader->load('services/controller.yaml');
$loader->load('services/security.yaml');
$loader->load('services/repositories.yaml');
$loader->load('services/workflow.yaml');
$loader->load('services/templating.yaml');
$loader->load('services/menu.yaml');
$loader->load('services/event.yaml');
$loader->load('services/timeline.yaml');
$loader->load('services/fixtures.yaml');
$loader->load('services/form.yaml');
}
public function prepend(ContainerBuilder $container)
@ -51,7 +51,7 @@ class ChillTaskExtension extends Extension implements PrependExtensionInterface
$container->prependExtensionConfig('chill_main', array(
'routing' => array(
'resources' => array(
'@ChillTaskBundle/Resources/config/routing.yml'
'@ChillTaskBundle/config/routes.yaml'
)
)
));

View File

@ -17,8 +17,8 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('chill_task');
$treeBuilder = new TreeBuilder('chill_task');
$rootNode = $treeBuilder->getRootNode('chill_task');
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for

View File

@ -10,7 +10,7 @@ use Doctrine\Common\Collections\Collection;
* SingleTask
*
* @ORM\Table(
* "chill_task.single_task",
* name="chill_task.single_task",
* indexes={
* @ORM\Index(
* name="by_type",

View File

@ -24,7 +24,7 @@ use Chill\TaskBundle\Entity\SingleTask;
*
*
* @ORM\Table(
* "chill_task.single_task_place_event",
* name="chill_task.single_task_place_event",
* indexes={
* @ORM\Index(
* name="transition_task_date",

View File

@ -40,17 +40,17 @@
<ul class="record_actions_column">
{% if task.startDate is not null %}
<li title="{{ 'Start'|trans|escape('html_attr') }}">
<i class="fa fa-play" ></i> {{ task.startDate|localizeddate('medium', 'none') }}
<i class="fa fa-play" ></i> {{ task.startDate|format_date('medium', 'none') }}
</li>
{% endif %}
{% if task.warningDate is not null %}
<li title="{{ 'Warning'|trans|escape('html_attr') }}">
<i class="fa fa-exclamation-triangle"></i> {{ task.warningDate|localizeddate('medium', 'none') }}
<i class="fa fa-exclamation-triangle"></i> {{ task.warningDate|format_date('medium', 'none') }}
</li>
{% endif %}
{% if task.endDate is not null %}
<li title="{{ 'End'|trans|escape('html_attr') }}">
<i class="fa fa-hourglass-end"></i> {{ task.endDate|localizeddate('medium', 'none') }}
<i class="fa fa-hourglass-end"></i> {{ task.endDate|format_date('medium', 'none') }}
</li>
{% endif %}
</ul>

View File

@ -1,4 +1,4 @@
{% extends "ChillPersonBundle::layout.html.twig" %}
{% extends "@ChillPerson/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_task_list' %}
{% set person = task.person %}
@ -7,7 +7,7 @@
{% block personcontent %}
{{ include('ChillMainBundle:Util:confirmation_template.html.twig',
{{ include('@ChillMain/Util/confirmation_template.html.twig',
{
'title' : 'Remove task'|trans,
'confirm_question' : 'Are you sure you want to remove the task about "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname } ),

View File

@ -14,7 +14,7 @@
* 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/>.
#}
{% extends "ChillPersonBundle::layout.html.twig" %}
{% extends "@ChillPerson/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_edit' %}
{% set person = task.person %}

View File

@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{% extends layout %}
{% extends "@ChillPerson/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_new' %}
@ -31,7 +31,8 @@
{# filter tasks #}
{% block filtertasks %}{#
sf4 check: prevent error message: `A block definition cannot be nested under non-capturing nodes.` #}
{% if person is not null %}
{% block personcontent %}
{% include 'ChillTaskBundle:SingleTask:_list.html.twig' %}
@ -43,3 +44,4 @@
</div>
{% endblock %}
{% endif %}
{% endblock %}

View File

@ -14,7 +14,7 @@
* 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/>.
#}
{% extends "ChillPersonBundle::layout.html.twig" %}
{% extends "@ChillPerson/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_new' %}
{% set person = task.person %}

View File

@ -14,7 +14,7 @@
* 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/>.
#}
{% extends "ChillPersonBundle::layout.html.twig" %}
{% extends "@ChillPerson/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_show' %}
{% set person = task.person %}
@ -62,17 +62,17 @@
{% else %}
{% if task.startDate is not null %}
<dt class="inline">{{ 'Start'|trans }}</dt>
<dd>{{ task.startDate|localizeddate('long', 'none') }}</dd>
<dd>{{ task.startDate|format_date('long', 'none') }}</dd>
{% endif %}
{% if task.endDate is not null %}
<dt class="inline">{{ 'End'|trans }}</dt>
<dd>{{ task.endDate|localizeddate('long', 'none') }}</dd>
<dd>{{ task.endDate|format_date('long', 'none') }}</dd>
{% endif %}
{% if task.warningDate is not null %}
<dt class="inline">{{ 'Warning'|trans }}</dt>
<dd>{{ task.warningDate|localizeddate('long', 'none') }}</dd>
<dd>{{ task.warningDate|format_date('long', 'none') }}</dd>
{% endif %}
{% endif %}

View File

@ -1,4 +1,4 @@
{% extends "ChillPersonBundle::layout.html.twig" %}
{% extends "@ChillPerson/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_task_list' %}
{% set person = task.person %}

View File

@ -1,6 +1,6 @@
<div>
<h3 class="single-line">
{{ event.datetime|localizeddate('long', 'none') }}
{{ event.datetime|format_date('long', 'none') }}
<span class="task"> / {{ 'Task'|trans }}</span> /
{% if transition is not null %}
<span class="statement">{{ task_workflow_metadata(event.task, 'transition.sentence', transition)|trans({ '%user%': event.author.username }) }}</span>
@ -25,7 +25,7 @@
{% if event.task.endDate is not empty %}
<dt class="inline">{{ 'Task end date'|trans }}</dt>
<dd>{{ event.task.endDate|localizeddate('medium', 'none') }}</dd>
<dd>{{ event.task.endDate|format_date('medium', 'none') }}</dd>
{% endif %}
</dl>
</div>

View File

@ -1,6 +1,6 @@
<div>
<h3 class="single-line">
{{ event.datetime|localizeddate('long', 'short') }}
{{ event.datetime|format_date('long', 'short') }}
<span class="task">
{% if transition is not null %}
<span class="statement">{{ task_workflow_metadata(event.task, 'transition.sentence', transition)|trans({ '%user%': event.author.username }) }}</span>

View File

@ -27,7 +27,7 @@ use Chill\TaskBundle\Workflow\TaskWorkflowManager;
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class TaskTwigExtension extends \Twig_Extension
class TaskTwigExtension extends AbstractExtension
{
/**
*

View File

@ -136,7 +136,14 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
public function getEntityTemplate($entity, $context, array $args)
{
$workflow = $this->registry->get($entity->getTask(), $entity->getData['workflow']);
$workflow = $this->registry->get($entity->getTask(),
(isset($entity->getData()['workflow'])) ? $entity->getData()['workflow'] : null
);
// sf4 check: prevent error message:
// `Notice: Undefined property: Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent::$getData`
// * fix syntax error on $entity->getData['workflow']
// * return null if not set
$transition = $this->getTransitionByName($entity->getTransition(), $workflow);
return [

View File

@ -18,8 +18,8 @@
namespace Chill\TaskBundle\Workflow;
use Chill\TaskBundle\Entity\AbstractTask;
use Symfony\Component\Workflow\SupportStrategy\SupportStrategyInterface;
use Symfony\Component\Workflow\Workflow;
use Symfony\Component\Workflow\SupportStrategy\WorkflowSupportStrategyInterface;
use Symfony\Component\Workflow\WorkflowInterface;
use Symfony\Component\Workflow\Event\Event;
/**
@ -27,7 +27,7 @@ use Symfony\Component\Workflow\Event\Event;
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class TaskWorkflowManager implements SupportStrategyInterface
class TaskWorkflowManager implements WorkflowSupportStrategyInterface
{
/**
*
@ -66,7 +66,7 @@ class TaskWorkflowManager implements SupportStrategyInterface
return $definitions[0];
}
public function supports(Workflow $workflow, $subject): bool
public function supports(WorkflowInterface $workflow, $subject): bool
{
if (!$subject instanceof AbstractTask) {
return false;

View File

@ -11,11 +11,9 @@
"classmap": [ "Resources/test/Fixtures/App/app/AppKernel.php" ]
},
"require": {
"chill-project/person": "~1.5"
},
"require-dev": {
"fzaninotto/faker": "^1.7",
"phpunit/phpunit": "^7.1"
},
"license": "AGPL-3.0-or-later",
"authors": [

View File

@ -1,9 +1,10 @@
services:
Chill\TaskBundle\Controller\:
resource: '../../../Controller'
resource: '../../Controller'
tags: ['controller.service_arguments']
Chill\TaskBundle\Controller\SingleTaskController:
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$timelineBuilder: '@chill_main.timeline_builder'
tags: ['controller.service_arguments']

View File

@ -1,4 +1,4 @@
services:
Chill\TaskBundle\DataFixtures\ORM\:
resource: ../../../DataFixtures/ORM
resource: ../../DataFixtures/ORM
tags: [ 'doctrine.fixture.orm' ]

View File

@ -5,6 +5,7 @@ services:
$registry: '@Symfony\Component\Workflow\Registry'
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
public: true
tags:
- { name: 'chill.timeline', context: 'person' }

View File

@ -2,7 +2,7 @@
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
@ -13,7 +13,7 @@ class Version20180413135614 extends AbstractMigration
/**
* @param Schema $schema
*/
public function up(Schema $schema)
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
@ -33,7 +33,7 @@ class Version20180413135614 extends AbstractMigration
/**
* @param Schema $schema
*/
public function down(Schema $schema)
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

View File

@ -2,7 +2,7 @@
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
@ -13,7 +13,7 @@ class Version20180413201023 extends AbstractMigration
/**
* @param Schema $schema
*/
public function up(Schema $schema)
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
@ -36,7 +36,7 @@ class Version20180413201023 extends AbstractMigration
/**
* @param Schema $schema
*/
public function down(Schema $schema)
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

View File

@ -2,7 +2,7 @@
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
@ -10,7 +10,7 @@ use Doctrine\DBAL\Schema\Schema;
*/
class Version20180426093011 extends AbstractMigration
{
public function up(Schema $schema)
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
@ -18,7 +18,7 @@ class Version20180426093011 extends AbstractMigration
$this->addSql('ALTER TABLE chill_task.recurring_task ADD closed BOOLEAN DEFAULT \'false\' NOT NULL');
}
public function down(Schema $schema)
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

View File

@ -2,7 +2,7 @@
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
@ -10,7 +10,7 @@ use Doctrine\DBAL\Schema\Schema;
*/
class Version20180502194119 extends AbstractMigration
{
public function up(Schema $schema)
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
@ -23,7 +23,7 @@ class Version20180502194119 extends AbstractMigration
$this->addSql('ALTER TABLE chill_task.single_task_place_event ADD CONSTRAINT FK_D459EBEE8DB60186 FOREIGN KEY (task_id) REFERENCES chill_task.single_task (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema)
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

View File

@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
*/
final class Version20181113161925 extends AbstractMigration
{
public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
@ -18,7 +18,7 @@ final class Version20181113161925 extends AbstractMigration
$this->addSql('CREATE INDEX transition_task ON chill_task.single_task_place_event (task_id, transition)');
}
public function down(Schema $schema) : void
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

View File

@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
*/
final class Version20181113164108 extends AbstractMigration
{
public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
@ -18,7 +18,7 @@ final class Version20181113164108 extends AbstractMigration
$this->addSql('CREATE INDEX by_current_state ON chill_task.single_task USING GIN (current_states)');
}
public function down(Schema $schema) : void
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

View File

@ -15,7 +15,6 @@ Scope: Cercle
Task: Tâche
Details: Détails
Person: Personne
Scope: Cercle
Date: Date
Dates: Dates
User: Utilisateur
@ -74,10 +73,10 @@ cancel: annuler
Start_verb: Démarrer
Close_verb: Clotûrer
Set this task to cancel state: Marquer cette tâche comme annulée
'%user% has closed the task': %user% a fermé la tâche
'%user% has canceled the task': %user% a annulé la tâche
'%user% has started the task': %user% a commencé la tâche
'%user% has created the task': %user% a introduit la tâche
'%user% has closed the task': '%user% a fermé la tâche'
'%user% has canceled the task': '%user% a annulé la tâche'
'%user% has started the task': '%user% a commencé la tâche'
'%user% has created the task': '%user% a introduit la tâche'
Are you sure you want to close this task ?: Êtes-vous sûrs de vouloir clotûrer cette tâche ?
Are you sure you want to cancel this task ?: Êtes-vous sûrs de vouloir annuler cette tâche ?
Are you sure you want to start this task ?: Êtes-vous sûrs de vouloir démarrer cette tâche ?