/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $startingTime = microtime(true); $this->bbapp = $this->getContainer()->get('bbapp'); $this->em = $this->bbapp->getEntityManager(); $this->output = $output; if ($input->getOption('verbose')) { $this->output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); } else { $this->output->setVerbosity(OutputInterface::VERBOSITY_NORMAL); } $this->em->getConnection()->getConfiguration()->setSQLLogger(null); $this->aclProvider = $this->bbapp->getSecurityContext()->getACLProvider(); $this->entitiesFinder = new EntityFinder(dirname($this->bbapp->getBBDir())); $this->classContentManager = $this->bbapp->getContainer()->get('classcontent.manager')->setBBUserToken($this->bbapp->getBBUserToken()); if (null !== $input->getOption('memory-limit')) { ini_set('memory_limit', $input->getOption('memory-limit')); } $outputCmd = ''; $outputCmd .= $input->getOption('memory-limit') !== null ? ' --m=' . $input->getOption('memory-limit') : ''; $outputCmd .= $input->getOption('user_name') !== null ? ' --user_name=' . $input->getOption('user_name') : ''; $outputCmd .= $input->getOption('user_password') !== null ? ' --user_password='******'user_password') : ''; $outputCmd .= $input->getOption('user_email') !== null ? ' --user_email=' . $input->getOption('user_email') : ''; $outputCmd .= $input->getOption('user_firstname') !== null ? ' --user_firstname=' . $input->getOption('user_firstname') : ''; $outputCmd .= $input->getOption('user_lastname') !== null ? ' --user_lastname=' . $input->getOption('user_lastname') : ''; $outputCmd .= $input->getOption('user_group') !== null ? ' --user_group=' . $input->getOption('user_group') : ''; $outputCmd .= $input->getOption('verbose') ? ' --v' : ''; $this->writeln(sprintf('BEGIN : users:update_rights %s', $outputCmd), OutputInterface::VERBOSITY_NORMAL); // Récupère le fichier users_rights.yml $usersRights = $this->bbapp->getConfig()->getGroupsConfig(); if (null === $this->aclProvider) { throw new \InvalidArgumentException('None ACL provider found'); } // Vérifier que les groups de droit sont bien définis if (false === is_array($usersRights)) { throw new \InvalidArgumentException('Malformed groups.yml file, aborting'); } if ($this->checksBackBeeVersion()) { // Vérification et mise à jour de la structure de la table user $this->checksUserTable(); // Vérification et mise à jour de la structure de la table group (anciennement groups) $this->checksGroupTable(); } // Traitement de l'option clean if ($input->getOption('clean')) { $this->writeln("\n" . '<info>[Cleaning all tables]</info>' . "\n"); $this->cleanTables(); $this->writeln(sprintf('Cleaning done in %d s.', microtime(true) - $startingTime)); } $this->writeln("\n" . '<info>[Check ACL tables existence]</info>' . "\n"); $this->checkAclTables(); // Update des droits $this->writeln("\n" . '<info>[Updating users rights]</info>' . "\n"); $this->updateRights($usersRights); // Update des utilisateurs $this->writeln("\n" . '<info>[Updating/Creating user]</info>' . "\n"); $this->updateUsers($usersRights, $input); $this->writeln(sprintf('<info>Update done in %d s.</info>', microtime(true) - $startingTime), OutputInterface::VERBOSITY_NORMAL); }