public function executeRefreshStep(dmWebRequest $request) { if ($request->hasParameter('dm_use_thread')) { $this->getServiceContainer()->mergeParameter('page_tree_watcher.options', array('use_thread' => $request->getParameter('dm_use_thread')))->reload('page_tree_watcher'); } $this->step = $request->getParameter('step'); try { switch ($this->step) { case 1: @$this->getService('cache_manager')->clearAll(); if ($this->getUser()->can('system')) { @$this->getService('filesystem')->sf('dmFront:generate'); @dmFileCache::clearAll(); } $data = array('msg' => $this->getI18n()->__('Page synchronization'), 'type' => 'ajax', 'url' => $this->getHelper()->link('+/dmCore/refreshStep')->param('step', 2)->getHref()); break; case 2: $this->getService('page_tree_watcher')->synchronizePages(); $data = array('msg' => $this->getI18n()->__('SEO synchronization'), 'type' => 'ajax', 'url' => $this->getHelper()->link('+/dmCore/refreshStep')->param('step', 3)->getHref()); break; case 3: $this->getService('page_tree_watcher')->synchronizeSeo(); if (count($this->getI18n()->getCultures()) > 1) { $this->getService('page_i18n_builder')->createAllPagesTranslations(); } $data = array('msg' => $this->getI18n()->__('Interface regeneration'), 'type' => 'redirect', 'url' => $this->getUser()->getAttribute('dm_refresh_back_url')); $this->context->getEventDispatcher()->notify(new sfEvent($this, 'dm.refresh', array())); $this->getUser()->getAttributeHolder()->remove('dm_refresh_back_url'); $this->getUser()->logInfo('Project successfully updated'); break; } } catch (Exception $e) { $this->getUser()->logError($this->getI18n()->__('Something went wrong when updating project')); $data = array('msg' => $this->getI18n()->__('Something went wrong when updating project'), 'type' => 'redirect', 'url' => $this->getUser()->getAttribute('dm_refresh_back_url')); if (sfConfig::get('sf_debug')) { if ($request->isXmlHttpRequest()) { $data['url'] = str_replace('dm_xhr=1', 'dm_xhr=0', $request->getUri() . '&dm_use_thread=0'); } else { throw $e; } } } return $this->renderJson($data); }
public function clearAll() { $success = true; dmFileCache::clearAll(); if (count($survivors = glob(sfConfig::get('sf_cache_dir') . '/*'))) { $success = false; $message = 'Can not be removed from cache : ' . implode(', ', $survivors); $this->dispatcher->notify(new sfEvent($this, 'application.log', array($message, 'priority' => sfLogger::ERR))); } if (dmAPCCache::isEnabled()) { if (!dmAPCCache::clearAll()) { $success = false; $message = 'Can not clear APC cache'; $this->dispatcher->notify(new sfEvent($this, 'application.log', array($message, 'priority' => sfLogger::ERR))); } } $this->dispatcher->notify(new sfEvent($this, 'dm.cache.clear', array('success' => $success))); $this->dispatcher->notify(new sfEvent($this, 'task.cache.clear')); return $success; }