예제 #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $force = $input->getOption('force');
     $drop = $input->getOption('drop');
     $this->bbapp = $this->getContainer()->get('bbapp');
     $this->em = $this->initConnection($input, $output);
     $this->checkBeforeUpdate();
     $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths([$this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'Bundle', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'Cache' . DIRECTORY_SEPARATOR . 'DAO', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'ClassContent', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'ClassContent' . DIRECTORY_SEPARATOR . 'Indexes', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'Logging', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'NestedNode', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'Security', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'Site', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'Stream' . DIRECTORY_SEPARATOR . 'ClassWrapper', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'Util' . DIRECTORY_SEPARATOR . 'Sequence' . DIRECTORY_SEPARATOR . 'Entity', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'Workflow']);
     $this->em->getConfiguration()->getMetadataDriverImpl()->addExcludePaths([$this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'ClassContent' . DIRECTORY_SEPARATOR . 'Tests', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'NestedNode' . DIRECTORY_SEPARATOR . 'Tests', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'Security' . DIRECTORY_SEPARATOR . 'Tests', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'Util' . DIRECTORY_SEPARATOR . 'Tests', $this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'Workflow' . DIRECTORY_SEPARATOR . 'Tests']);
     if (is_dir($this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'vendor')) {
         $this->em->getConfiguration()->getMetadataDriverImpl()->addExcludePaths([$this->bbapp->getBBDir() . DIRECTORY_SEPARATOR . 'vendor']);
     }
     $sqls = $this->getUpdateQueries();
     if ($force || $drop) {
         $metadata = $this->em->getMetadataFactory()->getAllMetadata();
         $schema = new SchemaTool($this->em);
         if ($drop) {
             $sqls = array_merge($schema->getDropDatabaseSQL(), $sqls);
         }
         if ($force) {
             $output->writeln('<info>Running drop/update</info>');
             $this->em->getConnection()->executeUpdate('SET FOREIGN_KEY_CHECKS=0');
             $drop ? $schema->dropDatabase() : '';
             $schema->updateSchema($metadata, true);
             $this->em->getConnection()->executeUpdate('SET FOREIGN_KEY_CHECKS=1');
         }
     }
     $output->writeln(($force ? '<info>SQL executed: </info>' : '<info>SQL to be executed: </info>') . PHP_EOL . implode(";" . PHP_EOL, $sqls) . '');
 }
예제 #2
0
 /**
  * Override Symfony\Component\Translation\Translator to lazy load every catalogs from:
  *     - BackBee\Resources\translations
  *     - PATH_TO_REPOSITORY\Resources\translations
  *     - PATH_TO_CONTEXT_REPOSITORY\Resources\translations.
  *
  * @param BBApplication $application
  * @param string        $locale
  */
 public function __construct(BBApplication $application, $locale)
 {
     parent::__construct($locale);
     // retrieve default fallback from container and set it
     $fallback = $application->getContainer()->getParameter('translator.fallback');
     $this->setFallbackLocales([$fallback]);
     // xliff is recommended by Symfony so we register its loader as default one
     $this->addLoader('xliff', new XliffFileLoader());
     // define in which directory we should looking at to find xliff files
     $dirToLookingAt = array($application->getBBDir() . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'translations', $application->getRepository() . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'translations');
     if ($application->getRepository() !== $application->getBaseRepository()) {
         $dirToLookingAt[] = $application->getBaseRepository() . 'Resources' . DIRECTORY_SEPARATOR . 'translations';
     }
     // loop in every directory we should looking at and load catalog from file which match to the pattern
     foreach ($dirToLookingAt as $dir) {
         if (true === is_dir($dir)) {
             foreach (scandir($dir) as $filename) {
                 preg_match('/(.+)\\.(.+)\\.xlf$/', $filename, $matches);
                 if (0 < count($matches)) {
                     $this->addResource('xliff', $dir . DIRECTORY_SEPARATOR . $filename, $matches[2], $matches[1]);
                 }
             }
         }
     }
 }
예제 #3
0
 /**
  * {@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);
 }
예제 #4
0
 /**
  * @return array
  */
 private function _getBackBeeSchema()
 {
     $classes = array();
     foreach ($this->_entityFinder->getEntities($this->_application->getBBDir()) as $className) {
         $classes[] = $this->_em->getClassMetadata($className);
     }
     return $classes;
 }