mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Simplify loading of Symfony commands.
This commit is contained in:
parent
ca9ae3874c
commit
5ddc0e7a53
@ -1,25 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
* Copyright (C) 2016-2019 Champs-Libres <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\PersonBundle\Command;
|
namespace Chill\PersonBundle\Command;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
@ -28,26 +10,15 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Symfony\Component\Console\Exception\RuntimeException;
|
use Symfony\Component\Console\Exception\RuntimeException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
|
||||||
class ChillPersonMoveCommand extends ContainerAwareCommand
|
final class ChillPersonMoveCommand extends Command
|
||||||
{
|
{
|
||||||
/**
|
private PersonMove $mover;
|
||||||
*
|
|
||||||
* @var PersonMove
|
|
||||||
*/
|
|
||||||
protected $mover;
|
|
||||||
|
|
||||||
/**
|
private EntityManagerInterface $em;
|
||||||
*
|
|
||||||
* @var EntityManagerInterface
|
|
||||||
*/
|
|
||||||
protected $em;
|
|
||||||
|
|
||||||
/**
|
private LoggerInterface $chillLogger;
|
||||||
*
|
|
||||||
* @var LoggerInterface
|
|
||||||
*/
|
|
||||||
protected $chillLogger;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
PersonMove $mover,
|
PersonMove $mover,
|
||||||
|
@ -1,22 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2016 Champs-Libres <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\PersonBundle\Command;
|
namespace Chill\PersonBundle\Command;
|
||||||
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
@ -40,61 +23,33 @@ use Symfony\Component\Console\Question\ConfirmationQuestion;
|
|||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
use Symfony\Component\Form\FormFactory;
|
use Symfony\Component\Form\FormFactory;
|
||||||
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
|
|
||||||
/**
|
final class ImportPeopleFromCSVCommand extends Command
|
||||||
* Class ImportPeopleFromCSVCommand
|
|
||||||
*
|
|
||||||
* @package Chill\PersonBundle\Command
|
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
||||||
*/
|
|
||||||
class ImportPeopleFromCSVCommand extends Command
|
|
||||||
{
|
{
|
||||||
/**
|
private InputInterface $input;
|
||||||
* @var InputInterface
|
|
||||||
*/
|
private OutputInterface $output;
|
||||||
protected $input;
|
|
||||||
|
private LoggerInterface $logger;
|
||||||
|
|
||||||
|
private TranslatableStringHelper $helper;
|
||||||
|
|
||||||
|
private EntityManagerInterface $em;
|
||||||
|
|
||||||
|
private EventDispatcherInterface $eventDispatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var OutputInterface
|
* The line currently read
|
||||||
*/
|
*/
|
||||||
protected $output;
|
private int $line;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Psr\Log\LoggerInterface
|
* Where key are column names, and value the custom field slug
|
||||||
*/
|
*/
|
||||||
protected $logger;
|
private array $customFieldMapping = [];
|
||||||
|
|
||||||
/**
|
private CustomFieldProvider $customFieldProvider;
|
||||||
* @var \Chill\MainBundle\Templating\TranslatableStringHelper
|
|
||||||
*/
|
|
||||||
protected $helper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Doctrine\Persistence\ObjectManager
|
|
||||||
*/
|
|
||||||
protected $em;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var EventDispatcherInterface
|
|
||||||
*/
|
|
||||||
protected $eventDispatcher;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the line currently read
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $line;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array where key are column names, and value the custom field slug
|
|
||||||
*/
|
|
||||||
protected $customFieldMapping = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var CustomFieldProvider
|
|
||||||
*/
|
|
||||||
protected $customFieldProvider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains an array of information searched in the file.
|
* Contains an array of information searched in the file.
|
||||||
@ -129,10 +84,7 @@ class ImportPeopleFromCSVCommand extends Command
|
|||||||
*/
|
*/
|
||||||
protected static $defaultDateInterpreter = "%d/%m/%Y|%e/%m/%y|%d/%m/%Y|%e/%m/%Y";
|
protected static $defaultDateInterpreter = "%d/%m/%Y|%e/%m/%y|%d/%m/%Y|%e/%m/%Y";
|
||||||
|
|
||||||
/**
|
private FormFactoryInterface $formFactory;
|
||||||
* @var FormFactory
|
|
||||||
*/
|
|
||||||
protected $formFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ImportPeopleFromCSVCommand constructor.
|
* ImportPeopleFromCSVCommand constructor.
|
||||||
@ -150,7 +102,7 @@ class ImportPeopleFromCSVCommand extends Command
|
|||||||
EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
CustomFieldProvider $customFieldProvider,
|
CustomFieldProvider $customFieldProvider,
|
||||||
EventDispatcherInterface $eventDispatcher,
|
EventDispatcherInterface $eventDispatcher,
|
||||||
FormFactory $formFactory
|
FormFactoryInterface $formFactory
|
||||||
) {
|
) {
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->helper = $helper;
|
$this->helper = $helper;
|
||||||
|
@ -69,7 +69,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
$loader->load('services/search.yaml');
|
$loader->load('services/search.yaml');
|
||||||
$loader->load('services/menu.yaml');
|
$loader->load('services/menu.yaml');
|
||||||
$loader->load('services/privacyEvent.yaml');
|
$loader->load('services/privacyEvent.yaml');
|
||||||
$loader->load('services/command.yaml');
|
|
||||||
$loader->load('services/actions.yaml');
|
$loader->load('services/actions.yaml');
|
||||||
$loader->load('services/form.yaml');
|
$loader->load('services/form.yaml');
|
||||||
$loader->load('services/alt_names.yaml');
|
$loader->load('services/alt_names.yaml');
|
||||||
|
@ -12,6 +12,13 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: 'serializer.normalizer', priority: 64 }
|
- { name: 'serializer.normalizer', priority: 64 }
|
||||||
|
|
||||||
|
Chill\PersonBundle\Command\:
|
||||||
|
resource: '../Command/'
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: console.command }
|
||||||
|
|
||||||
chill.person.form.type.select2maritalstatus:
|
chill.person.form.type.select2maritalstatus:
|
||||||
class: Chill\PersonBundle\Form\Type\Select2MaritalStatusType
|
class: Chill\PersonBundle\Form\Type\Select2MaritalStatusType
|
||||||
arguments:
|
arguments:
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
services:
|
|
||||||
Chill\PersonBundle\Command\ChillPersonMoveCommand:
|
|
||||||
arguments:
|
|
||||||
$em: '@Doctrine\ORM\EntityManagerInterface'
|
|
||||||
$mover: '@Chill\PersonBundle\Actions\Remove\PersonMove'
|
|
||||||
$chillLogger: '@chill.main.logger'
|
|
||||||
tags:
|
|
||||||
- { name: console.command }
|
|
||||||
|
|
||||||
Chill\PersonBundle\Command\ImportPeopleFromCSVCommand:
|
|
||||||
arguments:
|
|
||||||
$logger: '@logger'
|
|
||||||
$helper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
|
||||||
$em: '@Doctrine\ORM\EntityManagerInterface'
|
|
||||||
$customFieldProvider: '@Chill\CustomFieldsBundle\Service\CustomFieldProvider'
|
|
||||||
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
|
||||||
$formFactory: '@form.factory'
|
|
||||||
tags:
|
|
||||||
- { name: console.command }
|
|
Loading…
x
Reference in New Issue
Block a user