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