本文整理汇总了PHP中sfFilesystem类的典型用法代码示例。如果您正苦于以下问题:PHP sfFilesystem类的具体用法?PHP sfFilesystem怎么用?PHP sfFilesystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfFilesystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
$this->logSection('Create directory', "Visiteur");
$q = Doctrine_Query::create()->from('Visiteur v');
$visiteurs = $q->execute();
foreach ($visiteurs as $visiteur) {
$visiteur->createDataFolder();
}
$this->logSection('Create directory', "Interactif");
$q = Doctrine_Query::create()->from('Interactif i');
$interactifs = $q->execute();
foreach ($interactifs as $interactif) {
$interactif->createDataFolder();
}
$this->logSection('Create directory', "Exposition");
$q = Doctrine_Query::create()->from('Exposition v');
$expositions = $q->execute();
foreach ($expositions as $exposition) {
$exposition->createDataFolder();
}
$this->logSection('Create directory', "Medaille");
$fileSystem = new sfFilesystem();
$fileSystem->mkdirs(sfConfig::get('sf_web_dir') . "/medaille");
$this->logSection('Create directory', "MedailleType");
$fileSystem = new sfFilesystem();
$fileSystem->mkdirs(sfConfig::get('sf_web_dir') . "/medaille_type");
}
示例2: execute
public function execute($arguments = array(), $options = array())
{
$projectDir = UtilPsdf::fixPath($arguments['pjpath']);
$packagesDir = $projectDir . DIRECTORY_SEPARATOR . $arguments['pkpath'] . DIRECTORY_SEPARATOR;
if (is_dir($projectDir)) {
throw new sfCommandException(sprintf('The project "%s" already exists.', $projectDir));
}
$filesystem = new sfFilesystem();
// Create basic workspace structure
$skeletonDir = dirname(__FILE__) . '/../../data/generator/skeleton/psdfProject';
$finder = sfFinder::type('any')->discard('.sf');
$filesystem->mirror($skeletonDir, $projectDir, $finder);
// Actualizo tokens
$constants = array('PROJECT_NAME' => $arguments['pjname']);
$finder = sfFinder::type('file')->name('.project');
$filesystem->replaceTokens($finder->in($projectDir), '##', '##', $constants);
// Create packages files (subdir por cada macro)
$packages = $arguments['packages'];
foreach ($packages as $pack) {
if (!is_dir($packagesDir . $pack['macro'])) {
$filesystem->mkdirs($packagesDir . $pack['macro']);
}
$file = $packagesDir . $pack['macro'] . DIRECTORY_SEPARATOR . $pack['name'] . '.xpdl';
$filesystem->touch($file);
file_put_contents($file, $pack['xpdl']);
}
}
示例3: createDataFolder
public function createDataFolder()
{
$fileSystem = new sfFilesystem();
$oldumask = umask(0);
$fileSystem->mkdirs($this->getExpositionDataPath(), 0777);
$fileSystem->chmod($this->getExpositionDataPath(), 0777);
umask($oldumask);
}
示例4: installPluginAssets
/**
* Installs web content for a plugin.
*
* @param string $plugin The plugin name
* @param string $dir The plugin directory
*/
protected function installPluginAssets($plugin, $dir)
{
$webDir = $dir . DIRECTORY_SEPARATOR . 'web';
if (is_dir($webDir)) {
$filesystem = new sfFilesystem();
$filesystem->relativeSymlink($webDir, sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $plugin, true);
}
}
示例5: refresh_assets
function refresh_assets()
{
$uploadDir = dirname(__FILE__) . '/../fixtures/project/web/uploads';
sfToolkit::clearDirectory($uploadDir);
$finder = new sfFinder();
$filesystem = new sfFilesystem();
$filesystem->mirror(dirname(__FILE__) . '/../fixtures/assets', $uploadDir, $finder);
}
示例6: listenToClearCache
/**
* 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));
}
}
示例7: installPluginAssets
protected function installPluginAssets($name, $path)
{
$webDir = $path . '/web';
if (is_dir($webDir)) {
$filesystem = new sfFilesystem();
$filesystem->relativeSymlink($webDir, sfConfig::get('sf_web_dir') . '/' . $name, true);
}
}
示例8: delete
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);
}
}
示例9: save
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);
}
}
示例10: execute
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);
}
}
示例11: replaceTokens
/**
*
*/
protected function replaceTokens($file)
{
$properties = parse_ini_file(sfConfig::get('sf_config_dir') . '/properties.ini', true);
$constants = array('PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', 'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here', 'PACKAGE_NAME' => !is_null($this->package) ? $this->package : 'package name');
if (!is_readable($file)) {
throw new sfCommandException("Failed to replace tokens as file is not accessible.");
}
// customize service file
$sfFilesystem = new sfFilesystem();
$sfFilesystem->replaceTokens($file, '##', '##', $constants);
}
示例12: delete
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());
}
示例13: copyWebAssets
private function copyWebAssets($plugin, $dir)
{
$webDir = $dir . DIRECTORY_SEPARATOR . 'web';
$filesystem = new sfFilesystem();
if (is_dir($webDir)) {
$finder = sfFinder::type('any');
$this->dirctoryRecusiveDelete(sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $plugin);
$filesystem->mirror($webDir, sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $plugin, $finder);
}
return;
}
示例14: execute
public function execute($request)
{
$css = Doctrine::getTable('SnsConfig')->get('customizing_css');
$this->getResponse()->setContent($css);
$this->getResponse()->setContentType('text/css');
// cache
$filesystem = new sfFilesystem();
$dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'css';
@$filesystem->mkdirs($dir);
file_put_contents($dir . DIRECTORY_SEPARATOR . 'customizing.css', $css);
return sfView::NONE;
}
示例15: uninstallModelFiles
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);
}
}
}