本文整理汇总了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']);
}
}
示例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');
示例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');