Example #1
0
 /**
  * Return only new or need to be updated Bundles
  * skipVersion == false
  *
  * @return Bundle[]
  */
 public function getNewBundles()
 {
     $bundles = $this->bundleLocatorService->getAvailableBundles();
     $newBundles = [];
     foreach ($bundles as $bundle) {
         // Check whether this bundle has already been installed
         switch ($this->isRegisteredBundle($bundle)) {
             case Installer::STATUS_REGISTERED_NO:
                 $bundle->setStatus(Installer::STATUS_REGISTERED_NO);
                 $newBundles[] = $bundle;
                 break;
             case Installer::STATUS_REGISTERED_OLDER:
                 // Get the existing bundle.
                 /** @var Bundle $registeredBundle */
                 $registeredBundle = $this->em->getRepository('CampaignChainCoreBundle:Bundle')->findOneByName($bundle->getName());
                 // Update the existing bundle's data.
                 $registeredBundle->setDescription($bundle->getDescription());
                 $registeredBundle->setLicense($bundle->getLicense());
                 $registeredBundle->setAuthors($bundle->getAuthors());
                 $registeredBundle->setHomepage($bundle->getHomepage());
                 $registeredBundle->setVersion($bundle->getVersion());
                 $registeredBundle->setExtra($bundle->getExtra());
                 $registeredBundle->setStatus(Installer::STATUS_REGISTERED_OLDER);
                 $newBundles[] = $registeredBundle;
                 break;
             case Installer::STATUS_REGISTERED_SAME:
                 $bundle->setStatus(Installer::STATUS_REGISTERED_SAME);
                 break;
         }
     }
     return $newBundles;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $types = [];
     $listing = [];
     // If no option selected, all are active.
     if (!$input->getOption('config-only') && !$input->getOption('routing-only') && !$input->getOption('class-only') && !$input->getOption('security-only')) {
         $input->setOption('config-only', true);
         $input->setOption('routing-only', true);
         $input->setOption('class-only', true);
         $input->setOption('security-only', true);
     }
     if ($input->getOption('class-only')) {
         $types = array_merge($types, ['classes' => true]);
         $listing[] = 'Registering bundle classes of all CampaignChain modules in AppKernel.php.';
     }
     if ($input->getOption('config-only')) {
         $types = array_merge($types, ['configs' => true]);
         $listing[] = 'Registering config.yml files of all CampaignChain modules';
     }
     if ($input->getOption('routing-only')) {
         $types = array_merge($types, ['routings' => true]);
         $listing[] = 'Registering routing.yml files of all CampaignChain modules';
     }
     if ($input->getOption('security-only')) {
         $types = array_merge($types, ['security' => true]);
         $listing[] = 'Registering security.yml files of all CampaignChain modules';
     }
     $kernelRootDir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..';
     $devEnv = true;
     if ($input->getOption('env') == 'prod') {
         $devEnv = false;
     }
     $packages = new Package($kernelRootDir, $devEnv);
     $locator = new BundleLocator($kernelRootDir, $packages);
     $availableBundles = $locator->getAvailableBundles();
     $kernel = new Kernel($kernelRootDir);
     $kernel->parseBundlesForKernelConfig($availableBundles);
     $io->listing($listing);
     $kernel->register($types);
     $io->success('CampaignChain modules configuration files are updated');
 }