public function processForm(Form $form) { $this->tryCall('handleClear', array()); $values = $form->getValues(); if ($values['section'] === 'all') { $this->cacheManager->clean(); } elseif ($values['section'] === 'namespace') { try { $this->cacheManager->cleanNamespace($values['namespace']); } catch (InvalidArgumentException $e) { $this->flashMessage($e->getMessage(), 'warning'); return; } } elseif ($values['section'] === 'sessions') { $this->cacheManager->cleanSessions(); } $this->flashMessage($this->translator->translate('Cache has been cleared.'), 'success'); if (!$this->isAjax()) { $this->redirect('this'); } }
/** * Upgrade module. * * @param IModule $module * @param bool $withDependencies */ public function upgrade(IModule $module, $force = FALSE) { if ($this->getStatus($module) !== self::STATUS_INSTALLED) { throw new InvalidArgumentException("Module '{$module->getName()}' must be installed"); } $modules = $this->loadModuleConfig(); if ($module->getVersion() === $modules['modules'][$module->getName()][self::MODULE_VERSION]) { throw new InvalidArgumentException("Module '{$module->getName()}' is current"); } if (!$force) { $dependencyResolver = $this->createSolver(); $dependencyResolver->testUpgrade($module); } foreach ($module->getInstallers() as $class) { try { /** @var $installer IInstaller */ $installer = $this->context->createInstance($class); $installer->upgrade($module, $this->modules[$module->getName()][self::MODULE_VERSION], $module->getVersion()); } catch (Exception $e) { foreach ($module->getInstallers() as $class2) { if ($class === $class2) { break; } $installer = $this->context->createInstance($class2); $installer->downgrade($module, $module->getVersion(), $this->modules[$module->getName()][self::MODULE_VERSION]); } throw $e; } } $modules['modules'][$module->getName()] = array(self::MODULE_STATUS => self::STATUS_INSTALLED, self::MODULE_ACTION => self::ACTION_NONE, self::MODULE_CLASS => $module->getClassName(), self::MODULE_VERSION => $module->getVersion(), self::MODULE_PATH => $this->getFormattedPath($module->getPath()), self::MODULE_AUTOLOAD => $this->getFormattedPath($module->getAutoload()), self::MODULE_REQUIRE => $module->getRequire()); $this->saveModuleConfig($modules); $this->reloadInfo(); $this->reloadSystemContainer(); $this->cacheManager->clean(); $this->onUpgrade($this, $module); }