| Conditions | 2 |
| Paths | 2 |
| Total Lines | 23 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 22 | protected function execute(InputInterface $input, OutputInterface $output) { |
||
| 23 | $code = $input->getArgument('code'); |
||
| 24 | $name = $input->getArgument('name'); |
||
| 25 | |||
| 26 | $db = $this->getContainer()->get('doctrine') |
||
| 27 | ->getRepository('VivaitAuthBundle:Group') |
||
| 28 | ->findOneBy(array('role'=>$code)); |
||
| 29 | |||
| 30 | if($db) { |
||
| 31 | $output->writeln(sprintf("There is already a role (%s) with code: %s",$db->getName(),$db->getRole())); |
||
| 32 | return null; |
||
| 33 | } |
||
| 34 | |||
| 35 | $group = new Group(); |
||
| 36 | $group->setRole($code); |
||
| 37 | $group->setName($name); |
||
| 38 | |||
| 39 | $em = $this->getContainer()->get('doctrine')->getManager(); |
||
| 40 | $em->persist($group); |
||
| 41 | $em->flush(); |
||
| 42 | |||
| 43 | $output->writeln(sprintf("Success: A new role has been created (%s: %s)", $group->getRole(),$group->getName())); |
||
| 44 | } |
||
| 45 | } |