mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-18 16:24:24 +00:00
Command/CreateFieldsOnGroupCommand.php : re-indent + adding function to be more readable
This commit is contained in:
parent
101783b9f1
commit
0e5e87eb41
@ -32,9 +32,11 @@ use Symfony\Component\Yaml\Exception\ParseException;
|
|||||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Class for the command 'chill:custom_fields:populate_group' that
|
||||||
|
* Create custom fields from a yml file
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
* @author Marc Ducobu <marc.ducobu@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class CreateFieldsOnGroupCommand extends ContainerAwareCommand
|
class CreateFieldsOnGroupCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
@ -50,6 +52,21 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
|
|||||||
->addOption(self::ARG_DELETE, null, InputOption::VALUE_NONE,
|
->addOption(self::ARG_DELETE, null, InputOption::VALUE_NONE,
|
||||||
'If set, delete existing fields');
|
'If set, delete existing fields');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the existing custom fields for a given customFieldGroup
|
||||||
|
*
|
||||||
|
* @param CustomFieldsGroup $customFieldsGroup : The custom field group
|
||||||
|
*/
|
||||||
|
protected function deleteFieldsForCFGroup($customFieldsGroup)
|
||||||
|
{
|
||||||
|
$em = $this->getContainer()
|
||||||
|
->get('doctrine.orm.default_entity_manager');
|
||||||
|
|
||||||
|
foreach ($customFieldsGroup->getCustomFields() as $field) {
|
||||||
|
$em->remove($field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
@ -87,11 +104,8 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO : getCustomFields or getActiveCustomFields ?
|
|
||||||
if ($input->getOption(self::ARG_DELETE)) {
|
if ($input->getOption(self::ARG_DELETE)) {
|
||||||
foreach ($customFieldsGroup->getCustomFields() as $field) {
|
$this->deleteFieldsForCFGroup($customFieldsGroup);
|
||||||
$em->remove($field);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$fieldsInput = $this->_parse($input->getArgument(self::ARG_PATH),
|
$fieldsInput = $this->_parse($input->getArgument(self::ARG_PATH),
|
||||||
@ -154,9 +168,8 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
|
|||||||
private function _addFields(CustomFieldsGroup $group, $values, OutputInterface $output)
|
private function _addFields(CustomFieldsGroup $group, $values, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$cfProvider = $this->getContainer()->get('chill.custom_field.provider');
|
$cfProvider = $this->getContainer()->get('chill.custom_field.provider');
|
||||||
|
$em = $this->getContainer()->get('doctrine.orm.default_entity_manager');
|
||||||
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
|
|
||||||
|
|
||||||
$languages = $this->getContainer()
|
$languages = $this->getContainer()
|
||||||
->getParameter('chill_main.available_languages');
|
->getParameter('chill_main.available_languages');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user