當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfFilesystem::touch方法代碼示例

本文整理匯總了PHP中sfFilesystem::touch方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfFilesystem::touch方法的具體用法?PHP sfFilesystem::touch怎麽用?PHP sfFilesystem::touch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfFilesystem的用法示例。


在下文中一共展示了sfFilesystem::touch方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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']);
     }
 }
開發者ID:psdf,項目名稱:psdfCorePlugin,代碼行數:27,代碼來源:psdfGenerateProject.class.php

示例2: Chart

$t->isa_ok($sha1, 'string', '->save() creates a sha for each chart');
$g->setKilometersFrom(235);
$g->save();
$sha2 = $g->getHash();
$t->cmp_ok($sha1, '!=', $sha2, '->save() The hash field is updated each time the object is changed');
$g = new Chart();
$g->setFormat('png');
$g->setKilometersTo(12423);
$g->setUserId($ut->getUserId('ruf'));
$g->link('Vehicles', array($ut->getVehicleId('vw-touran-1-4-tsi')));
$g->link('Categories', array($ut->getIdForCategory('Fuel')));
$sha = $g->getHash();
$g2 = new Chart();
$g2->setUserId($ut->getUserId('ruf'));
$g->save();
$finalsha = $g->getHash();
$t->isnt($sha, $finalsha, 'When saving the object, ->save() checks that a unique sha is set. If not, a new one is generated.');
// ->delete()
$t->diag('->delete()');
$g = new Chart();
$g->setUserId($ut->getUserId('ruf'));
$g->save();
$id = $g->getId();
$path = $g->getChartFileSystemPath();
$fs = new sfFilesystem(new sfEventDispatcher());
$fs->touch($path);
$t->cmp_ok(file_exists($path), '===', true, 'A Chart may have an associated figure file.');
$g->delete();
$g2 = Doctrine_Core::getTable('Chart')->findOneById($id);
$t->cmp_ok($g2, '===', false, '->delete() deletes the chart from the DB');
$t->cmp_ok(file_exists($path), '===', false, '->delete() also deletes the image associated to the Chart');
開發者ID:rbolliger,項目名稱:otokou,代碼行數:31,代碼來源:chartTest.php

示例3: catch

    $fs->remove($fullpath);
}
$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');
開發者ID:rbolliger,項目名稱:otokou,代碼行數:31,代碼來源:chartBuilderTest.php


注:本文中的sfFilesystem::touch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。