refactoring Command/CreateFieldsOnGroupCommand.php : code indent

This commit is contained in:
Marc Ducobu 2015-09-29 20:20:14 +02:00
parent afc51d2f31
commit 653112ba57

View File

@ -38,7 +38,6 @@ use Chill\CustomFieldsBundle\Entity\CustomField;
*/ */
class CreateFieldsOnGroupCommand extends ContainerAwareCommand class CreateFieldsOnGroupCommand extends ContainerAwareCommand
{ {
const ARG_PATH = 'path'; const ARG_PATH = 'path';
const ARG_DELETE = 'delete'; const ARG_DELETE = 'delete';
@ -49,8 +48,7 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
->addArgument(self::ARG_PATH, InputOption::VALUE_REQUIRED, ->addArgument(self::ARG_PATH, InputOption::VALUE_REQUIRED,
'Path to description file') 'Path to description file')
->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');
;
} }
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
@ -61,8 +59,7 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
$customFieldsGroups = $em $customFieldsGroups = $em
->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') ->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')
->findAll() ->findAll();
;
if (count($customFieldsGroups) === 0) { if (count($customFieldsGroups) === 0) {
$output->writeln('<error>There aren\'t any CustomFieldsGroup recorded' $output->writeln('<error>There aren\'t any CustomFieldsGroup recorded'
@ -90,6 +87,7 @@ 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) { foreach ($customFieldsGroup->getCustomFields() as $field) {
$em->remove($field); $em->remove($field);
@ -100,8 +98,6 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
$output); $output);
$fields = $this->_addFields($customFieldsGroup, $fieldsInput, $output); $fields = $this->_addFields($customFieldsGroup, $fieldsInput, $output);
} }
private function _prepareRows ($customFieldsGroups) private function _prepareRows ($customFieldsGroups)
@ -152,7 +148,6 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
throw new \RunTimeException("The yaml file is not valid", 0, $ex); throw new \RunTimeException("The yaml file is not valid", 0, $ex);
} }
return $values; return $values;
} }
@ -179,8 +174,7 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
->setOptions(isset($field['options']) ? $field['options'] : array() ) ->setOptions(isset($field['options']) ? $field['options'] : array() )
->setOrdering($field['ordering']) ->setOrdering($field['ordering'])
->setType($field['type']) ->setType($field['type'])
->setCustomFieldsGroup($group) ->setCustomFieldsGroup($group);
;
//add to table //add to table
$names = array(); $names = array();
@ -191,7 +185,6 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
'Not available in this language'; 'Not available in this language';
} }
if ($this->getContainer()->get('validator')->validate($cf)) { if ($this->getContainer()->get('validator')->validate($cf)) {
$em->persist($cf); $em->persist($cf);
$output->writeln("<info>Adding Custom Field of type " $output->writeln("<info>Adding Custom Field of type "
@ -200,7 +193,6 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
} else { } else {
throw new \RunTimeException("Error in field ".$slug); throw new \RunTimeException("Error in field ".$slug);
} }
} }
$em->flush(); $em->flush();