Ejemplo n.º 1
0
 protected function getPlugin(InputInterface $input, $fromKernel = true)
 {
     $bundleName = $input->getArgument('bundle');
     $kernel = $this->getContainer()->get('kernel');
     if ($fromKernel) {
         return $kernel->getBundle($bundleName);
     }
     $detector = new Detector();
     $bundles = $detector->detectBundles($kernel->getRootDir() . '/../vendor');
     foreach ($bundles as $bundleFqcn) {
         $parts = explode('\\', $bundleFqcn);
         $name = array_pop($parts);
         if ($name === $bundleName) {
             $bundle = new $bundleFqcn($kernel);
             if (!$bundle instanceof PluginBundle) {
                 throw new \Exception("Bundle {$bundle->getName()} must extend PluginBundle");
             }
             return $bundle;
         }
     }
     throw new \Exception("Cannot found bundle '{$bundleName}' in the vendor directory");
 }