protected function _executeAction($action, $pluginName) { try { sfToolkit::clearGlob(sfConfig::get('sf_cache_dir')); $manager = sfSympalPluginManager::getActionInstance($pluginName, $action); $manager->{$action}(); sfToolkit::clearGlob(sfConfig::get('sf_cache_dir')); $this->getUser()->setFlash('notice', $pluginName . ' "' . $action . '" action executed successfully!'); return true; } catch (Exception $e) { $this->getUser()->setFlash('error', $pluginName . ' "' . $action . '" action failed with error "' . $e->getMessage() . '"!' . (sfConfig::get('sf_debug') ? "<br/><br/>" . nl2br($e->getTraceAsString()) : null)); return false; } }
protected function getsfEmailTemplateOrCreate($id = 'id') { if (!$this->getRequestParameter($id)) { $sf_email_template = new sfEmailTemplate(); } else { $sf_email_template = sfEmailTemplatePeer::retrieveByPk($this->getRequestParameter($id)); $this->forward404Unless($sf_email_template); } // delete existing email templates cached file so the changes are applied immediately $cache_file = sfConfig::get('sf_root_dir') . '/cache/frontend/prod/config/config_db_emailtemplates.yml.php'; sfToolkit::clearGlob($cache_file); $cache_file = sfConfig::get('sf_root_dir') . '/cache/backend/prod/config/config_db_emailtemplates.yml.php'; sfToolkit::clearGlob($cache_file); return $sf_email_template; }
public function executeSystemParameters(sfWebRequest $request) { $error = 0; $this->forward404Unless($request->isMethod(sfRequest::POST)); //If the HTTP method is "post", get the values entered by the user: $this->values = array('ip_address' => $this->getRequestParameter('ip_address'), 'srv_port' => $this->getRequestParameter('srv_port'), 'dbms' => $this->getRequestParameter('dbms') + 1, 'db_name' => $this->getRequestParameter('db_name'), 'db_user_name' => $this->getRequestParameter('db_user_name'), 'db_password' => $this->getRequestParameter('db_password'), '_csrf_token' => $this->getRequestParameter('_csrf_token')); //Build the form with theses values: $form = new SystemParametersForm($this->values); //Execute the validators of this form: $form->bind($this->values); //If everything is fine: if ($form->isValid()) { //Insert the new values in the xml configuration file:*/ ParametersConfiguration::setBddParams($this->values); ParametersConfiguration::editYaml(); sfToolkit::clearGlob(sfConfig::get('sf_cache_dir') . '/install/*'); $this->redirect('firstBoot/stepTwo'); } else { $this->form = $form; $this->setTemplate("stepOne"); } }
sfToolkit::clearDirectory($tmp_dir); $t->ok(!is_dir($tmp_dir.DIRECTORY_SEPARATOR.'foo'), '::clearDirectory() removes all directories from the directory parameter'); $t->ok(!is_file($tmp_dir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar'), '::clearDirectory() removes all directories from the directory parameter'); $t->ok(!is_file($tmp_dir.DIRECTORY_SEPARATOR.'test'), '::clearDirectory() removes all directories from the directory parameter'); rmdir($tmp_dir); // ::clearGlob() $t->diag('::clearGlob()'); $tmp_dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.'symfony_tests_'.rand(1, 999); mkdir($tmp_dir); mkdir($tmp_dir.DIRECTORY_SEPARATOR.'foo'); mkdir($tmp_dir.DIRECTORY_SEPARATOR.'bar'); file_put_contents($tmp_dir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar', 'ok'); file_put_contents($tmp_dir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'foo', 'ok'); file_put_contents($tmp_dir.DIRECTORY_SEPARATOR.'bar'.DIRECTORY_SEPARATOR.'bar', 'ok'); sfToolkit::clearGlob($tmp_dir.'/*/bar'); $t->ok(!is_file($tmp_dir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar'), '::clearGlob() removes all files and directories matching the pattern parameter'); $t->ok(!is_file($tmp_dir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar'), '::clearGlob() removes all files and directories matching the pattern parameter'); $t->ok(is_file($tmp_dir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'foo'), '::clearGlob() removes all files and directories matching the pattern parameter'); sfToolkit::clearDirectory($tmp_dir); rmdir($tmp_dir); // ::arrayDeepMerge() $t->diag('::arrayDeepMerge()'); $t->is( sfToolkit::arrayDeepMerge(array('d' => 'due', 't' => 'tre'), array('d' => 'bis', 'q' => 'quattro')), array('d' => 'bis', 't' => 'tre', 'q' => 'quattro'), '::arrayDeepMerge() merges linear arrays preserving literal keys' ); $t->is( sfToolkit::arrayDeepMerge(array('d' => 'due', 't' => 'tre', 'c' => array('c' => 'cinco')), array('d' => array('due', 'bis'), 'q' => 'quattro', 'c' => array('c' => 'cinque', 'c2' => 'cinco'))),
private function _deletePluginFiles() { $this->logSection('sympal', 'Removing plugin files'); Doctrine_Lib::removeDirectories($this->_pluginPath); if ($this->_contentTypeName) { chdir(sfConfig::get('sf_root_dir')); $task = new sfDoctrineDeleteModelFilesTask($this->_dispatcher, $this->_formatter); foreach ($this->getPluginModels() as $model) { $task->run(array($model), array('--no-confirmation')); } } $path = sfConfig::get('sf_lib_dir') . '/*/doctrine/' . $this->_pluginName; $dirs = glob($path); sfToolkit::clearGlob($path); foreach ($dirs as $dir) { Doctrine_Lib::removeDirectories($dir); } if ($this->hasWebDirectory()) { unlink(sfConfig::get('sf_web_dir') . '/' . $this->_pluginName); } }
protected function removeGloballyFromCache($items) { $cache_dir = sfConfig::get('sf_root_cache_dir') . '/frontend/*/template/*/*'; $cache_dir .= sfConfig::get('sf_no_script_name') ? '/' : '/*/'; foreach ($items as $item) { c2cTools::log('{cache} removing : ' . $cache_dir . $item); sfToolkit::clearGlob($cache_dir . $item); } }
// Remove private data Doctrine_Query::create()->delete()->from('UserPrivateData')->addWhere("id = '{$userid_to_wipe}'")->execute(); $conn->commit(); } catch (Exception $e) { $conn->rollback(); echo "A problem occured during merging\n"; throw $e; } // Clear cache - We cannot use function from c2cActions since it is protected $cache_dir = sfConfig::get('sf_root_cache_dir') . '/frontend/*/template/*/all'; $cache_dir .= sfConfig::get('sf_no_script_name') ? '/' : '/*/'; //c2cActions::clearCache('users', $userid_to_wipe, false); $toRemove[] = "users/*/id/{$userid_to_wipe}/*"; //c2cActions::clearCache('users', $userid_to_remain, false); $toRemove[] = "users/*/id/{$userid_to_remain}/*"; // find all docs associated to user_id_to_remain and clear the cache $associated_docs = Association::findAllAssociatedDocs($userid_to_remain, array('id', 'module')); foreach ($associated_docs as $doc) { //c2cActions::clearCache($doc['module'], $doc['id'], false, 'view'); $toRemove[] = "{$doc['module']}/view/id/{$doc['id']}/*"; } // find all geo associated docs $associated_docs = GeoAssociation::findAllAssociatedDocs($userid_to_remain, array('id', 'module')); foreach ($associated_docs as $doc) { //c2cActions::clearCache($doc['module'], $doc['id'], false, 'view'); $toRemove[] = "{$doc['module']}/view/id/{$doc['id']}/*"; } foreach ($toRemove as $item) { sfToolkit::clearGlob($cache_dir . $item); } echo "Users successfully merged\n";
public function executeCc() { $path = sfConfig::get('sf_cache_dir'); if (glob($path)) { @sfToolkit::clearGlob($path); } $this->text = "Done"; }
/** * Clear cache for view / history , diff and list after a new comment has been posted * rq: comment page is not cached */ public static function clearCommentCache($id, $lang = null, $module = '*') { $cache_dir = sfConfig::get('sf_root_cache_dir') . '/frontend/*/template/*/*'; $cache_dir .= sfConfig::get('sf_no_script_name') ? '/' : '/*/'; $items = array("{$module}/history/id/{$id}/", "{$module}/view/id/{$id}/", "{$module}/diff/id/{$id}/"); foreach ($items as $item) { $item .= $lang == null ? '*' : "lang/{$lang}/*"; c2cTools::log('{cache} removing : ' . $cache_dir . $item); sfToolkit::clearGlob($cache_dir . $item); } // Clear cache for list : $item = "{$module}/list/*"; c2cTools::log('{cache} removing : ' . $cache_dir . $item); sfToolkit::clearGlob($cache_dir . $item); }