public static function execute($arguments = array(), $options = array()) { $app = $arguments['application']; $module = $arguments['module']; $action = $arguments['action']; $process = $arguments['process']; $activity = $arguments['activity']; $scripts = $arguments['scripts']; // Fuerzo el cero (0) si no contiene valor if (!$activity['is_autocomplete']) { $activity['is_autocomplete'] = '0'; } $actionDir = sfConfig::get('sf_apps_dir') . '/' . $app . '/modules/' . $module . '/actions'; $templateDir = sfConfig::get('sf_apps_dir') . '/' . $app . '/modules/' . $module . '/templates'; $actionFile = $action . 'Action.class.php'; $templateFile = $action . 'Success.php'; $errorFile = $action . 'Error.php'; $filesystem = new sfFilesystem(); if (!is_dir($actionDir)) { throw new sfCommandException(sprintf("No se pudo identificar el modulo symfony '%s' implementacion del paquete '%s'", $actionDir, $module)); } if (is_file($actionDir . '/' . $actionFile)) { // Borro el archivo porque lo voy a recrear $filesystem->remove($actionDir . '/' . $actionFile); //throw new sfCommandException(sprintf('The action "%s" already exists.', $actionFile)); } if (is_file($templateDir . '/' . $templateFile)) { // Borro el archivo porque lo voy a recrear $filesystem->remove($templateDir . '/' . $templateFile); //throw new sfCommandException(sprintf('The template "%s" already exists.', $templateFile)); } // Activity Type determine skeleton if ($activity['type'] == 'StartEvent') { $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/startAction.class.php'; } elseif ($activity['type'] == 'EndEvent') { $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/endAction.class.php'; } elseif ($activity['type'] == 'TaskUser' or $activity['type'] == 'TaskManual') { $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityUserAction.class.php'; $skeletonTemplate = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityUserSuccess.php'; $skeletonError = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityUserError.php'; } else { $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityAction.class.php'; } // create basic action $filesystem->copy($skeletonAction, $actionDir . '/' . $actionFile); // customize action $constants = array('ACTIVITY' => $action, 'ACTIVITY_NAME' => $activity['name'], 'MODULE' => $module, 'PROCESS_ID' => $process['id'], 'PROCESS_NAME' => $process['name'], 'SET_DATAFIELDS' => $scripts['set_datafields'], 'PTN_NAME' => $scripts['ptn_name'], 'PTN_SET_PARAMS' => $scripts['ptn_set_params'], 'PTN_URL_TEMPLATE' => file_exists($scripts['ptn_url_template']) ? file_get_contents($scripts['ptn_url_template']) : '', 'RULES_NEXT' => $scripts['rules_next'], 'ACTIVITY_AUTOCOMPLETE' => $activity['is_autocomplete']); $finder = sfFinder::type('file')->name($actionFile); $filesystem->replaceTokens($finder->in($actionDir), '##', '##', $constants); // Personalize template Success y Error if ($activity['type'] == 'TaskUser' or $activity['type'] == 'TaskManual') { $filesystem->copy($skeletonTemplate, $templateDir . '/' . $templateFile); $finder = sfFinder::type('file')->name($templateFile); $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants); $filesystem->copy($skeletonError, $templateDir . '/' . $errorFile); $finder = sfFinder::type('file')->name($errorFile); $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants); } }
public function cleanup(sfFilesystem $filesystem) { sfToolkit::clearDirectory(sfConfig::get('sf_log_dir')); sfToolkit::clearDirectory(dmOs::join(sfConfig::get('sf_web_dir'), 'cache')); sfToolkit::clearDirectory(dmOs::join(sfConfig::get('sf_root_dir'), 'cache')); sfToolkit::clearDirectory(sfConfig::get('sf_web_dir') . '/themeAdmin'); $filesystem->remove(sfFinder::type('any')->not_name('*.sqlite')->in(sfConfig::get('sf_data_dir'))); $filesystem->remove(sfFinder::type('file')->name('sitemap*')->in(sfConfig::get('sf_web_dir'))); copy(dmOs::join(sfConfig::get('sf_data_dir'), 'fresh_db.sqlite'), dmOs::join(sfConfig::get('sf_data_dir'), 'db.sqlite')); $this->cleanupUploads($filesystem); $this->removeWebSymlinks(); }
public function uninstallModelFiles($plugin) { $filesystem = new sfFilesystem(); $baseDir = sfConfig::get('sf_lib_dir'); $subpackages = array('model', 'form', 'filter'); foreach ($subpackages as $subpackage) { $targetDir = $baseDir . DIRECTORY_SEPARATOR . $subpackage . DIRECTORY_SEPARATOR . 'doctrine' . DIRECTORY_SEPARATOR . $plugin; if (is_dir($targetDir)) { $filesystem->remove(sfFinder::type('any')->in($targetDir)); $filesystem->remove($targetDir); } } }
/** * Unnstalls web content for a plugin. * * @param string $plugin The plugin name */ public function uninstallWebContent($plugin) { $targetDir = $this->environment->getOption('web_dir') . DIRECTORY_SEPARATOR . $plugin; if (is_dir($targetDir)) { $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Uninstalling web data for plugin'))); $filesystem = new sfFilesystem(); if (is_link($targetDir)) { $filesystem->remove($targetDir); } else { $filesystem->remove(sfFinder::type('any')->in($targetDir)); $filesystem->remove($targetDir); } } }
/** * Clear dynamics folder cache. */ static function listenToClearCache(sfEvent $event) { $dymanics_cache_path = sfConfig::get('sf_web_dir') . '/dynamics'; if (file_exists($dymanics_cache_path)) { $filesystem = new sfFilesystem(new sfEventDispatcher(), new sfFormatter()); $filesystem->remove(sfFinder::type('file')->discard('.sf')->in($dymanics_cache_path)); } }
public function save() { Doctrine::getTable('SnsConfig')->set('customizing_css', $this->getValue('css')); $filesystem = new sfFilesystem(); $cssPath = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'customizing.css'; if (is_file($cssPath)) { @$filesystem->remove($cssPath); } }
public function delete(Doctrine_Connection $conn = null) { parent::delete($conn); $path = $this->getChartPath('system'); if (file_exists($path)) { $fs = new sfFilesystem(new sfEventDispatcher()); $fs->remove($path); } }
public function delete(Doctrine_Connection $conn = null) { $guid = $this->getGuid(); parent::delete($conn); $delete_log = new DeleteLog(); $delete_log->setGuid($guid); $delete_log->setModelName(get_class($this)); $delete_log->save(); $fileSystem = new sfFilesystem(); @$fileSystem->remove($this->getInteractifDataPath()); }
public function _doUpgrade() { $this->logSection('sympal', 'Moving model/form/filter files from lib/*/doctrine/sfSympalPlugin to lib/*/doctrine/sfSympalCMFPlugin'); $finder = sfFinder::type('file'); $filesystem = new sfFilesystem($this->_dispatcher, $this->_formatter); foreach ($this->_dirs as $origin => $destination) { $this->logSection('sympal', sprintf('Mirroring %s to %s', $origin, $destination)); $filesystem->mirror(sfConfig::get('sf_root_dir') . '/' . $origin, sfConfig::get('sf_root_dir') . '/' . $destination, $finder); $this->logSection('sympal', sprintf('Deleting %s', $origin)); // remove the files first foreach ($finder->in(sfConfig::get('sf_root_dir') . '/' . $origin) as $file) { $filesystem->remove(sfConfig::get('sf_root_dir') . '/' . $origin . '/' . $file); } // remove the dirs $dirs = array(sfConfig::get('sf_root_dir') . '/' . $origin . '/base', sfConfig::get('sf_root_dir') . '/' . $origin); foreach ($dirs as $dir) { if (file_exists($dir)) { $filesystem->remove($dir); } } } }
public static function writeCacheFile($pathToCacheFile, $content) { $filesystem = new sfFilesystem(); $currentUmask = umask(); umask(00); $tmpFile = tempnam(dirname($pathToCacheFile), basename($pathToCacheFile)); if (!($fp = @fopen($tmpFile, 'wb'))) { throw new sfCacheException('Failed to write cache file.'); } @fwrite($fp, $content); @fclose($fp); if (!@rename($tmpFile, $pathToCacheFile)) { if ($filesystem->copy($tmpFile, $pathToCacheFile, array('override' => true))) { $filesystem->remove($tmpFile); } } $filesystem->chmod($pathToCacheFile, 0666); umask($currentUmask); }
public function clearWebCache($params = array()) { $dir = sfConfig::get('sf_web_dir') . '/cache/'; if (is_dir($dir)) { $filesystem = new sfFilesystem(); @$filesystem->remove(sfFinder::type('any')->in($dir)); } }
/** * Publishes Web Assets for third party themes. Originally written to be used * in tasks only, readapted to be used in whole application * * @author Yevgeniy Viktorov <*****@*****.**> * Giansimon Diblas <*****@*****.**> * * @param Array * @param Array * * @return Array - Contain the description of the generated assets publishing events * */ public function unpublishAsset($param, $filesystem = null) { $result = ''; $theme = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $param; if (is_dir($theme)) { if ($filesystem == null) { $filesystem = new sfFilesystem(); } $filesystem->remove($theme); $result = 'Unpublished assets for ' . $param; } return $result; }
public function executeDelete(sfWebRequest $request) { $request->checkCSRFProtection(); $this->forward404Unless($ad = Doctrine_Core::getTable('Ad')->find(array($request->getParameter('id'))), sprintf('Object ad does not exist (%s).', $request->getParameter('id'))); //Get user Id $userId = $this->getUser()->getGuardUser()->getId(); //Get company owned by that user $companyUserId = CompanyTable::getInstance()->findOneByUserId($userId)->getId(); //Get id number sent by the user (never trust the users) $adId = $request->getParameter('id'); $companyId = AdTable::getInstance()->findOneById($adId)->getCompanyId(); $this->forward404Unless($companyId == $companyUserId, sprintf('Ad does not exist (%s).', $request->getParameter('id'))); //Remove picture from file system. $fs = new sfFilesystem(); $fs->remove(sfConfig::get('app_default_picture_directory') . $ad->getAdMobileImage()); //Remove ad from database. $ad->delete(); $this->redirect('ad/index'); }
protected function importSCMFile($pear, $memberId, $dir) { $filesystem = new sfFilesystem(); $info = $pear->infoFromDescriptionFile($dir . '/package.xml'); if ($info instanceof PEAR_Error) { throw new RuntimeException($info->message()); } $filename = sprintf('%s-%s.tgz', $info['name'], $info['version']); opPluginChannelServerToolkit::generateTarByPluginDir($info, $filename, $dir, sfConfig::get('sf_cache_dir')); $file = $this->getImportedPluginFile($filename, sfConfig::get('sf_cache_dir') . '/' . $filename); $release = Doctrine::getTable('PluginRelease')->createByPackageInfo($info, $file, $memberId, file_get_contents($dir . '/package.xml')); $this->package->PluginRelease[] = $release; $this->package->save(); $filesystem = new sfFilesystem(); sfToolkit::clearDirectory($dir); $filesystem->remove($dir); $filesystem->remove(sfConfig::get('sf_cache_dir') . '/' . $filename); }
public function clearPluginCache($params = array()) { $appConfiguration = $params['app']; $environment = $params['env']; $subDir = sfConfig::get('sf_cache_dir') . '/' . $appConfiguration->getApplication() . '/' . $environment . '/plugins'; if (is_dir($subDir)) { $filesystem = new sfFilesystem(); $filesystem->remove(sfFinder::type('any')->discard('.sf')->in($subDir)); } }
public static function clearAssetCache(sfFilesystem $fileSystem) { $assetDir = aFiles::getUploadFolder(array('asset-cache')); $fileSystem->remove(sfFinder::type('file')->in($assetDir)); $cache = aAssets::getCache(); $cache->clean(); }
$g->checkPath($g->getChartsSystemPath(), false); $t->ok(!file_exists(sfConfig::get('sf_web_dir') . $path), '->getChartsSystemPath() accepts a "create" option. If set to false, the path is not created, if not found.'); try { $g->checkPath($g->getChartsWebPath()); $t->fail('no code should be executed after throwing an exception'); } catch (Exception $e) { $t->pass('->checkPath() only accepts system paths'); } // ->chartSourceIsAvailable() $t->diag('->chartSourceIsAvailable()'); $g = newChart(); $t->cmp_ok($g->chartSourceIsAvailable(), '===', false, 'Chart source file is not available for new charts'); $fs = new sfFilesystem(); $fs->touch($g->getChartFileSystemPath()); $t->cmp_ok($g->chartSourceIsAvailable(), '===', true, 'Chart source file is found, if it exists'); $fs->remove($g->getChartFileSystemPath()); $fs->remove($g->getChartsSystemPath()); // ->getAttributes() $t->diag('->getAttributes()'); $attr = array('test' => 'sdfgdg'); $g = newChart(array(), array(), $attr); $t->cmp_ok($g->getAttributes(), '===', $attr, '->getAttributes() returns attributes set via ChartBuilder constructor'); // ->addAttributes() $t->diag('->addAttributes()'); $attr2 = array('a1234' => '34'); $g->addAttributes($attr2); $t->cmp_ok($g->getAttributes(), '===', array_merge($attr, $attr2), '->addAttributes() appends new attributes'); // ->setAttributes() $attr = array('dfsdf' => 'asdfgsdg'); $g->setAttributes($attr); $t->cmp_ok($g->getAttributes(), '===', $attr, '->setAttributes() resets ChartBuilder attributes and adds new ones');
protected function execute($arguments = array(), $options = array()) { $bashrcPath = $_SERVER['HOME'] . '/.bashrc'; $userCompletionPath = $options['path'] ? $options['path'] : $_SERVER['HOME'] . '/.symfony_completion'; $systemCompletionPath = $options['path'] ? $options['path'] : '/etc/bash_completion.d/symfony'; $completionCode = ' if [ -f ~/.symfony_completion ]; then . ~/.symfony_completion fi '; $completionFunction = '_symfony() { if [ -f data/bash_completion ] ; then source data/bash_completion _symfony_local fi } complete -F _symfony symfony '; if ($options['system']) { if (file_exists($systemCompletionPath) && !$options['force']) { $this->logBlock('File "' . $systemCompletionPath . '" already exists! If you realy want to rewrite it use --force (-f) option', 'ERROR'); } else { if (file_put_contents($systemCompletionPath, $completionFunction)) { $this->logSection('+file', $systemCompletionPath); $this->logSection('Attention!', 'You need to restart terminal to complete this task'); } else { $this->logBlock('File "' . $systemCompletionPath . '" is not writable! Try to run this task with sudo or check --path option', 'ERROR'); } } } elseif ($options['user']) { if (file_put_contents($userCompletionPath, $completionFunction)) { $this->logSection('+file', $userCompletionPath); } else { $this->logBlock('File "' . $userCompletionPath . '" is not writable! Try to run this task with sudo or check --path option', 'ERROR'); return; } if (strstr(file_get_contents($bashrcPath), $completionCode)) { $this->logBlock('File "' . $bashrcPath . '" has already installed completion script. Not touching.', 'INFO'); } elseif (file_put_contents($bashrcPath, $completionCode, FILE_APPEND)) { $this->logSection('modified', $bashrcPath); } else { $this->logBlock('File "' . $bashrcPath . '" is not writable! Aborting.', 'ERROR'); return; } $this->logSection('Attention!', 'You need to restart terminal to complete this task'); } elseif ($options['cleanup']) { if (file_exists($userCompletionPath)) { $fs = new sfFilesystem($this->dispatcher, $this->formatter); $fs->remove($userCompletionPath); } else { $this->logBlock('File "' . $userCompletionPath . '" does not exists.', 'INFO'); } if (is_writable($bashrcPath)) { $bashrc = file_get_contents($bashrcPath); if (strstr($bashrc, $completionCode)) { file_put_contents($bashrcPath, str_replace($completionCode, '', $bashrc)); $this->logSection('modified', $bashrcPath); } else { $this->logBlock('File "' . $bashrcPath . '" already clean.', 'INFO'); } } else { $this->logBlock('File "' . $bashrcPath . '" is not writable or does not exist!', 'ERROR'); } } else { $tasks = $this->commandApplication->getTasks(); foreach ($tasks as $name => &$task) { $opts = array(); foreach ($task->getOptions() as $option) { $opts[] = '--' . $option->getName() . ($option->isParameterRequired() ? '=' : ''); if ($option->getShortcut()) { $opts[] = '-' . $option->getShortcut(); } } $opts = implode(' ', $opts); $task = "\t\t\"{$name}\")\n\t\t\tCOMPREPLY=(\$(compgen -W \"{$opts}\" -- \$cur)) ;;"; } $names = implode(' ', array_keys($tasks)); $opts = implode("\n", $tasks); $script = '_symfony_local() { local cur prev words cword _get_comp_words_by_ref -n : cur prev words cword if [[ cword -eq 1 ]] ; then COMPREPLY=($(compgen -W "%s" -- $cur)) __ltrim_colon_completions "$cur" return 0 fi if [[ ${cur:0:1} != "-" ]] ; then COMPREPLY=($(compgen -A file -- ${words[cword]})) return 0 fi COMPREPLY=($(compgen -A file -- ${words[cword]})) case ${words[1]} in %s esac } '; $script = sprintf($script, $names, $opts); $path = $options['path'] ? $options['path'] : sfConfig::get('sf_data_dir') . '/bash_completion'; file_put_contents($path, $script); chown($path, get_current_user()); $this->logSection('+file', $path); } }
/** Removes anything in the uploads directory. * * @return static */ public function flushUploads() { $Filesystem = new sfFilesystem(); $Filesystem->remove(sfFinder::type('any')->in(sfConfig::get('sf_upload_dir'))); return $this; }
public function execute($arguments = array(), $options = array()) { $this->logSection('psdf:generate-activity', sprintf("Generando actividad '%s'...", $arguments['activity'])); $this->logSection('psdf:generate-activity', sprintf("Nombre: '%s' Id: '%s' Type: '%s'", $arguments['activity'], $this->psdf_activity_data['id'], $this->psdf_activity_data['type'])); //$this->log( 'Datos de la actividad:' ); //$this->log( sfYaml::dump($this->psdf_activity_data) ); // -------------------------------- // Creo la accion y template correspondiente // -------------------------------- // Nombres de actividad parseado a implementar $action = str_replace(' ', '_', $arguments['activity']); $actionDir = sfConfig::get('sf_apps_dir') . '/' . $arguments['macro'] . '/modules/' . $arguments['package'] . '/actions'; $templateDir = sfConfig::get('sf_apps_dir') . '/' . $arguments['macro'] . '/modules/' . $arguments['package'] . '/templates'; $actionFile = $action . 'Action.class.php'; $templateFile = $action . 'Success.php'; $errorFile = $action . 'Error.php'; $filesystem = new sfFilesystem(); if (!is_dir($actionDir)) { throw new sfCommandException(sprintf("No existe el directorio '%s' del modulo '%s' sobre el cual implementar la accion '%s'", $actionDir, $arguments['package'], $action)); } if (is_file($actionDir . '/' . $actionFile)) { // Borro el archivo porque lo voy a recrear $filesystem->remove($actionDir . '/' . $actionFile); //throw new sfCommandException(sprintf('The action "%s" already exists.', $actionFile)); } if (is_file($templateDir . '/' . $templateFile)) { // Borro el archivo porque lo voy a recrear $filesystem->remove($templateDir . '/' . $templateFile); //throw new sfCommandException(sprintf('The template "%s" already exists.', $templateFile)); } // Activity Type determine skeleton $skeletonAction = dirname(__FILE__) . sprintf('/skeleton/activity/action/%sAction.class.php', $this->psdf_activity_data['type']); $skeletonTemplate = dirname(__FILE__) . sprintf('/skeleton/activity/template/%sSuccess.php', $this->psdf_activity_data['type']); $skeletonError = dirname(__FILE__) . sprintf('/skeleton/activity/template/%sError.php', $this->psdf_activity_data['type']); if (!is_file($skeletonAction)) { throw new sfCommandException(sprintf("No hay definido un esqueleto para crear la actividad del tipo '%s'", $this->psdf_activity_data['type'])); } // -------------------------------- // Personalizacion comun a todas las actividades // -------------------------------- $scripts['set_datafields'] = $this->genScriptSetDatafield(); $scripts['rules_next'] = $this->genScriptNextActivity(); $scripts['pattern'] = $this->genScriptsPattern(); // customize action $constants = array('ACTION' => $action, 'MODULE' => $arguments['package'], 'PROCESS_ID' => $arguments['process_id'], 'RULES_NEXT' => $scripts['rules_next'], 'SET_DATAFIELDS' => $scripts['set_datafields'], 'PTN_NAME' => $scripts['pattern']['name'], 'PTN_SET_PARAMS' => $scripts['pattern']['set_parameter'], 'PTN_SET_TEMPLATE' => $scripts['pattern']['set_template'], 'PTN_SET_DATAFIELDS' => $scripts['pattern']['set_datafield'], 'PROCESS_NAME' => $arguments['process'], 'ACTIVITY_NAME' => $arguments['activity']); // create basic action $filesystem->copy($skeletonAction, $actionDir . '/' . $actionFile); $finder = sfFinder::type('file')->name($actionFile); $filesystem->replaceTokens($finder->in($actionDir), '##', '##', $constants); if (is_file($skeletonTemplate)) { $filesystem->copy($skeletonTemplate, $templateDir . '/' . $templateFile); $finder = sfFinder::type('file')->name($templateFile); $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants); } if (is_file($skeletonError)) { $filesystem->copy($skeletonError, $templateDir . '/' . $errorFile); $finder = sfFinder::type('file')->name($errorFile); $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants); } $this->logSection('psdf:generate-activity', sprintf("Fin generacion actividad", $arguments['activity'])); }
public static function clearCache() { $filesystem = new sfFilesystem(); $filesystem->remove(sfFinder::type('file')->discard('.sf')->in(sfConfig::get('sf_cache_dir'))); @$filesystem->remove(sfFinder::type('file')->in(sfConfig::get('sf_web_dir') . '/cache/')); }
if (!isset($version)) { throw new Exception('Unable to find last SVN revision.'); } // make a PEAR compatible version $version = $version_prefix . '.' . $version; } else { $version = $argv[1]; } print sprintf("Releasing symfony version \"%s\".\n", $version); // tests $result = $filesystem->sh('php data/bin/symfony symfony:test'); if (0 != $result) { throw new Exception('Some tests failed. Release process aborted!'); } if (is_file('package.xml')) { $filesystem->remove(getcwd() . DIRECTORY_SEPARATOR . 'package.xml'); } $filesystem->copy(getcwd() . '/package.xml.tmpl', getcwd() . '/package.xml'); // add class files $finder = sfFinder::type('file')->relative(); $xml_classes = ''; $dirs = array('lib' => 'php', 'data' => 'data'); foreach ($dirs as $dir => $role) { $class_files = $finder->in($dir); foreach ($class_files as $file) { $xml_classes .= '<file role="' . $role . '" baseinstalldir="symfony" install-as="' . $file . '" name="' . $dir . '/' . $file . '" />' . "\n"; } } // replace tokens $filesystem->replaceTokens(getcwd() . DIRECTORY_SEPARATOR . 'package.xml', '##', '##', array('SYMFONY_VERSION' => $version, 'CURRENT_DATE' => date('Y-m-d'), 'CLASS_FILES' => $xml_classes, 'STABILITY' => $stability)); $results = $filesystem->sh('pear package');
* @subpackage test * @author Dejan Spasic <*****@*****.**> * @version SVN: $Id: bootstrap.php 20057 2009-07-09 13:40:40Z Dejan.Spasic $ */ // Autofind the first available app environment $sfRootDir = realpath(dirname(__FILE__) . '/../../../'); $appsDir = glob($sfRootDir . '/apps/*', GLOB_ONLYDIR); $app = substr($appsDir[0], strrpos($appsDir[0], DIRECTORY_SEPARATOR) + 1, strlen($appsDir[0])); if (!$app) { throw new Exception('No app has been detected in this project'); } // -- path to the symfony project where the plugin resides $sfPath = dirname(__FILE__) . '/../../..'; // bootstrap include $sfPath . '/test/bootstrap/unit.php'; // initialize database manager new sfDatabaseManager(ProjectConfiguration::getActive()); // initialize database connection for our tests Doctrine_Manager::connection('sqlite::memory:', '_test_graphiz'); // clean the model directory try { $_fs = new sfFilesystem(); $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/_files/model'), RecursiveIteratorIterator::CHILD_FIRST); foreach ($it as $file) { $_fs->remove($file->getPathname()); } $_fs->remove(dirname(__FILE__) . '/_files/model'); } catch (Exception $e) { } // generate the model Doctrine::generateModelsFromYaml(dirname(__FILE__) . '/_files', dirname(__FILE__) . '/_files/model');
public static function clearFileCache($filename) { $sizes = array_merge(self::getAllowedSize(), array('raw')); $formats = self::getAllowedFormat(); $filesystem = new sfFilesystem(); foreach ($sizes as $size) { if ('raw' !== $size) { $s = explode('x', $size); $width = $s[0]; $height = $s[1]; } else { $width = $height = ''; } foreach ($formats as $format) { $path = self::getPathToFileCache($format, $width, $height, $filename); if (is_file($path)) { @$filesystem->remove($path); } } } }
protected function tearDown() { $fileSystem = new sfFilesystem(); $fileSystem->remove(sfFinder::type('file')->discard('.sf')->in(sfConfig::get('sf_cache_dir') . '/ohrmKeyValueCache')); }