/** * Here we generate a new operation.xml file. */ public function generateUniqueOperationFile($bundle, $version, $bundleType, $fqcn, $logFile) { $entity = $this->getBundle($bundle); $isInstalled = false; if ($entity) { $oldVersion = $entity->getVersion(); $isInstalled = true; } $operationFilePath = $this->kernelRootDir . "/config/operations.xml"; //remove the old operation file if it exists (maybe it would be better to do a backup). @unlink($operationFilePath); $fileLogger = new \Monolog\Logger('package.update'); $fileLogger->pushHandler(new \Monolog\Handler\StreamHandler($logFile)); $operationHandler = new OperationHandler($operationFilePath, $fileLogger); //generating the operations.xml file $operation = new Operation($isInstalled ? Operation::UPDATE : Operation::INSTALL, $fqcn, $bundleType === 'claroline-plugin' ? Operation::BUNDLE_PLUGIN : Operation::BUNDLE_CORE); if (isset($entity)) { $operation->setFromVersion($oldVersion); } $operation->setToVersion($version); $operation->setDependencies(array()); $operationHandler->addOperation($operation, false); }
$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); } //generating the operations.xml file foreach ($bundles as $bundle) { $operation = new Operation($bundle['is_installed'] ? Operation::UPDATE : Operation::INSTALL, $bundle['fqcn'], $bundle['type'] === 'claroline-plugin' ? Operation::BUNDLE_PLUGIN : Operation::BUNDLE_CORE); if (isset($bundle['old_version'])) { $operation->setFromVersion($bundle['old_version']); } $operation->setToVersion($bundle['new_version']); $operation->setDependencies($bundle['dependencies']); $operationHandler->addOperation($operation, false); } //Build the bundle file $recorder->buildBundleFile(); //reboot the kernel for the new bundle file $kernel->shutdown(); $kernel->boot(); //install from the operation file $container = $kernel->getContainer(); /** @var \Claroline\CoreBundle\Library\Installation\PlatformInstaller $installer */ $installer = $container->get('claroline.installation.platform_installer'); //assets & assetic dump