* 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'; \$loader->add('%s', '%s');
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))); } } //retrieve the already installed bundles $sql = "SELECT * from `claro_bundle`"; $res = $conn->query($sql); $operations = []; foreach ($res->fetchAll() as $installedBundle) { foreach ($bundles as &$bundle) { if ($bundle['name'] === $installedBundle['name']) { $bundle['is_installed'] = true; $bundle['old_version'] = $installedBundle['version']; } } //removing last ref unset($bundle);