mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	Command/CreateFieldsOnGroupCommand.php : re-indent + adding function to be more readable
This commit is contained in:
		| @@ -32,9 +32,11 @@ use Symfony\Component\Yaml\Exception\ParseException; | ||||
| 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 Marc Ducobu <marc.ducobu@champs-libres.coop> | ||||
|  */ | ||||
| class CreateFieldsOnGroupCommand extends ContainerAwareCommand | ||||
| { | ||||
| @@ -50,6 +52,21 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand | ||||
|             ->addOption(self::ARG_DELETE, null, InputOption::VALUE_NONE, | ||||
|                 '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) | ||||
|     { | ||||
| @@ -87,11 +104,8 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand | ||||
|             } | ||||
|         ); | ||||
|            | ||||
|         // TODO : getCustomFields or getActiveCustomFields ? | ||||
|         if ($input->getOption(self::ARG_DELETE)) { | ||||
|             foreach ($customFieldsGroup->getCustomFields() as $field) { | ||||
|                 $em->remove($field); | ||||
|             } | ||||
|             $this->deleteFieldsForCFGroup($customFieldsGroup); | ||||
|         } | ||||
|              | ||||
|         $fieldsInput = $this->_parse($input->getArgument(self::ARG_PATH),  | ||||
| @@ -154,9 +168,8 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand | ||||
|     private function _addFields(CustomFieldsGroup $group, $values, OutputInterface $output) | ||||
|     { | ||||
|         $cfProvider = $this->getContainer()->get('chill.custom_field.provider'); | ||||
|          | ||||
|         $em = $this->getContainer()->get('doctrine.orm.entity_manager'); | ||||
|          | ||||
|         $em = $this->getContainer()->get('doctrine.orm.default_entity_manager'); | ||||
|  | ||||
|         $languages = $this->getContainer() | ||||
|             ->getParameter('chill_main.available_languages'); | ||||
|          | ||||
|   | ||||
		Reference in New Issue
	
	Block a user