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"); }
* This script appends the bundle to be tested to bundles.ini * and registers its namespace in the autoloader (these steps * are necessary because the bundle was used as the root package * during the execution of composer). **************************************************************/ require __DIR__ . '/autoload.php'; use Claroline\BundleRecorder\Detector\Detector; // convert errors to exceptions set_error_handler(function ($severity, $message, $file, $line) { throw new ErrorException($message, 0, $severity, $file, $line); }); if (count($argv) < 2) { echo "The bundle directory must be passed as argument\n"; exit(1); } $detector = new Detector(); $bundle = $detector->detectBundle($argv[1]); $bundleFile = __DIR__ . '/config/bundles.ini'; $bundles = file_get_contents($bundleFile); $bundles .= "\n{$bundle} = true"; file_put_contents($bundleFile, $bundles); echo "Updated bundles.ini with target bundle:\n{$bundle}\n\n"; $bundleParts = explode('\\', $bundle); array_pop($bundleParts); $bundleNamespace = implode('\\', $bundleParts); $loaderMask = <<<SRC <?php use Doctrine\\Common\\Annotations\\AnnotationRegistry; \$loader = require __DIR__ . '/../vendor/autoload.php';
$host = $value['parameters']['database_host']; $dbName = $value['parameters']['database_name']; //dsn driver... hardcoded. Change this if you really need it. //or use the connexion from sf2 $driver = 'mysql'; $dsn = "{$driver}:host={$host};dbname={$dbName}"; $username = $value['parameters']['database_user']; $password = $value['parameters']['database_password']; //create connection $conn = new \PDO($dsn, $username, $password, array()); //Let's use stefk stuff ! $operationFilePath = __DIR__ . "/../../app/config/operations.xml"; //remove the old operation file if it exists (maybe it would be better to do a backup). unlink($operationFilePath); $operationHandler = new OperationHandler($operationFilePath); $detector = new Detector($vendorDir); $bundleHandler = new BundleHandler($configDir . '/bundles.ini'); $recorder = new Recorder(new Detector($vendorDir), new BundleHandler($configDir . '/bundles.ini'), new OperationHandler($configDir . '/operations.xml'), $vendorDir); $recorder->buildBundleFile(); $kernel = new AppKernel('prod', false); $kernel->loadClassCache(); //I need to do that in order to access some services required for the installation... $kernel->boot(); $bundles = array(); //retrieve the current bundles foreach ($recorder->getOperations() as $operation) { $package = $operation->getPackage(); if ($package->getType() === 'claroline-plugin' || $package->getType() === 'claroline-core') { $bundles[] = array('type' => $package->getType(), 'name' => $package->getPrettyName(), 'new_version' => $package->getVersion(), 'is_installed' => false, 'fqcn' => $detector->detectBundle($package->getPrettyName()), 'dependencies' => array($recorder->getDependencies($package))); } }