本文整理汇总了PHP中PhingFile类的典型用法代码示例。如果您正苦于以下问题:PHP PhingFile类的具体用法?PHP PhingFile怎么用?PHP PhingFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhingFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setOptions
private function setOptions($pkg)
{
$options['baseinstalldir'] = 'phing';
$options['packagedirectory'] = $this->dir->getAbsolutePath();
if (empty($this->filesets)) {
throw new BuildException("You must use a <fileset> tag to specify the files to include in the package.xml");
}
$options['filelistgenerator'] = 'Fileset';
// Some PHING-specific options needed by our Fileset reader
$options['phing_project'] = $this->getProject();
$options['phing_filesets'] = $this->filesets;
if ($this->packageFile !== null) {
// create one w/ full path
$f = new PhingFile($this->packageFile->getAbsolutePath());
$options['packagefile'] = $f->getName();
// must end in trailing slash
$options['outputdirectory'] = $f->getParent() . DIRECTORY_SEPARATOR;
$this->log("Creating package file: " . $f->getPath(), Project::MSG_INFO);
} else {
$this->log("Creating [default] package.xml file in base directory.", Project::MSG_INFO);
}
if ($this->mode == "docs") {
$options['dir_roles'] = array('phing_guide' => 'doc', 'api' => 'doc', 'example' => 'doc');
} else {
// add install exceptions
$options['installexceptions'] = array('bin/phing.php' => '/', 'bin/pear-phing' => '/', 'bin/pear-phing.bat' => '/');
$options['dir_roles'] = array('etc' => 'data');
$options['exceptions'] = array('bin/pear-phing.bat' => 'script', 'bin/pear-phing' => 'script', 'CREDITS' => 'doc', 'CHANGELOG' => 'doc', 'README' => 'doc', 'UPGRADE' => 'doc', 'TODO' => 'doc');
}
$pkg->setOptions($options);
}
开发者ID:namesco,项目名称:phing,代码行数:31,代码来源:BuildPhingPEARPackageTask.php
示例2: setDir
public function setDir(PhingFile $dir)
{
if (!$dir->exists()) {
throw new BuildException("Can not find asset directory: " . $dir->getAbsolutePath(), $this->location);
}
$this->assetDir = $dir->getAbsolutePath();
}
开发者ID:rcrowe,项目名称:phing-asset,代码行数:7,代码来源:Assets.php
示例3: main
public function main()
{
if (empty($this->filesets)) {
throw new BuildException("You must specify a file or fileset(s).");
}
if (empty($this->_compilePath)) {
throw new BuildException("You must specify location for compiled templates.");
}
date_default_timezone_set("America/New_York");
$project = $this->getProject();
$this->_count = $this->_total = 0;
$smartyCompilePath = new PhingFile($this->_compilePath);
if (!$smartyCompilePath->exists()) {
$this->log("Compile directory does not exist, creating: " . $smartyCompilePath->getPath(), Project::MSG_VERBOSE);
if (!$smartyCompilePath->mkdirs()) {
throw new BuildException("Error creating compile path for Smarty in " . $this->_compilePath);
}
}
$this->_smarty = new Smarty();
$this->_smarty->use_sub_dirs = true;
$this->_smarty->compile_dir = $smartyCompilePath;
$this->_smarty->plugins_dir[] = $this->_pluginsPath;
$this->_smarty->force_compile = $this->_forceCompile;
// process filesets
foreach ($this->filesets as $fs) {
$ds = $fs->getDirectoryScanner($project);
$fromDir = $fs->getDir($project);
$srcFiles = $ds->getIncludedFiles();
$this->_compile($fromDir, $srcFiles);
}
$this->log("Compiled " . $this->_count . " out of " . $this->_total . " Smarty templates");
}
开发者ID:hellogerard,项目名称:phing-things,代码行数:32,代码来源:SmartyCompileTask.php
示例4: read
/**
* Returns the stream with an additional linebreak.
*
* @return the resulting stream, or -1
* if the end of the resulting stream has been reached
*
* @throws IOException if the underlying stream throws an IOException
* during reading
*/
function read($len = null)
{
if ($this->processed === true) {
return -1;
// EOF
}
// Read
$php = null;
while (($buffer = $this->in->read($len)) !== -1) {
$php .= $buffer;
}
if ($php === null) {
// EOF?
return -1;
}
if (empty($php)) {
$this->log("File is empty!", Project::MSG_WARN);
return '';
// return empty string
}
// write buffer to a temporary file, since php_strip_whitespace() needs a filename
$file = new PhingFile(tempnam(PhingFile::getTempDir(), 'stripwhitespace'));
file_put_contents($file->getAbsolutePath(), $php);
$output = file_get_contents($file->getAbsolutePath()) . "\r\n";
unlink($file->getAbsolutePath());
$this->processed = true;
return $output;
}
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:37,代码来源:AddLinebreak.php
示例5: build
/**
* Uses a builder class to create the output class.
* This method assumes that the DataModelBuilder class has been initialized with the build properties.
*
* @param OMBuilder $builder
* @param boolean $overwrite Whether to overwrite existing files with te new ones (default is YES).
*
* @todo -cPropelOMTask Consider refactoring build() method into AbstractPropelDataModelTask (would need to be more generic).
* @return int
*/
protected function build(OMBuilder $builder, $overwrite = true)
{
$path = $builder->getClassFilePath();
$this->ensureDirExists(dirname($path));
$_f = new PhingFile($this->getOutputDirectory(), $path);
// skip files already created once
if ($_f->exists() && !$overwrite) {
$this->log("\t-> (exists) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
return 0;
}
$script = $builder->build();
foreach ($builder->getWarnings() as $warning) {
$this->log($warning, Project::MSG_WARN);
}
// skip unchanged files
if ($_f->exists() && $script == $_f->contents()) {
$this->log("\t-> (unchanged) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
return 0;
}
// write / overwrite new / changed files
$action = $_f->exists() ? 'Updating' : 'Creating';
$this->log(sprintf("\t-> %s %s (table: %s, builder: %s)", $action, $builder->getClassFilePath(), $builder->getTable()->getName(), get_class($builder)));
file_put_contents($_f->getAbsolutePath(), $script);
return 1;
}
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:35,代码来源:PropelOMTask.php
示例6: selectionTest
/**
* This test is our selection test that compared the file with the destfile.
*
* @param PhingFile $srcfile the source file
* @param PhingFile $destfile the destination file
* @return bool true if the files are different
*
* @throws BuildException
*/
protected function selectionTest(PhingFile $srcfile, PhingFile $destfile)
{
try {
// if either of them is missing, they are different
if ($srcfile->exists() !== $destfile->exists()) {
return true;
}
if ($srcfile->length() !== $destfile->length()) {
// different size => different files
return true;
}
if (!$this->ignoreFileTimes) {
// different dates => different files
if ($destfile->lastModified() !== $srcfile->lastModified()) {
return true;
}
}
if (!$this->ignoreContents) {
//here do a bulk comparison
$fu = new FileUtils();
return !$fu->contentEquals($srcfile, $destfile);
}
} catch (IOException $e) {
throw new BuildException("while comparing {$srcfile} and {$destfile}", $e);
}
return false;
}
开发者ID:Geeklog-Japan,项目名称:geeklog-japan,代码行数:36,代码来源:DifferentSelector.php
示例7: parseFile
/**
* {@inheritDoc}
*/
public function parseFile(PhingFile $file)
{
if (!$file->canRead()) {
throw new IOException("Unable to read file: " . $file);
}
try {
// We load the Yaml class without the use of namespaces to prevent
// parse errors in PHP 5.2.
$parserClass = '\\Symfony\\Component\\Yaml\\Parser';
$parser = new $parserClass();
// Cast properties to array in case parse() returns null.
$properties = (array) $parser->parse(file_get_contents($file->getAbsolutePath()));
} catch (Exception $e) {
if (is_a($e, '\\Symfony\\Component\\Yaml\\Exception\\ParseException')) {
throw new IOException("Unable to parse contents of " . $file . ": " . $e->getMessage());
}
throw $e;
}
$flattenedProperties = $this->flattenArray($properties);
foreach ($flattenedProperties as $key => $flattenedProperty) {
if (is_array($flattenedProperty)) {
$flattenedProperties[$key] = implode(',', $flattenedProperty);
}
}
return $flattenedProperties;
}
开发者ID:Geeklog-Japan,项目名称:geeklog-japan,代码行数:29,代码来源:YamlFileParser.php
示例8: setOptions
private function setOptions($pkg)
{
$options['baseinstalldir'] = 'propel';
$options['packagedirectory'] = $this->dir->getAbsolutePath();
if (empty($this->filesets)) {
throw new BuildException("You must use a <fileset> tag to specify the files to include in the package.xml");
}
$options['filelistgenerator'] = 'Fileset';
// Some PHING-specific options needed by our Fileset reader
$options['phing_project'] = $this->getProject();
$options['phing_filesets'] = $this->filesets;
if ($this->packageFile !== null) {
// create one w/ full path
$f = new PhingFile($this->packageFile->getAbsolutePath());
$options['packagefile'] = $f->getName();
// must end in trailing slash
$options['outputdirectory'] = $f->getParent() . DIRECTORY_SEPARATOR;
$this->log("Creating package file: " . $f->getPath(), Project::MSG_INFO);
} else {
$this->log("Creating [default] package.xml file in base directory.", Project::MSG_INFO);
}
// add install exceptions
$options['installexceptions'] = array('pear/pear-propel-gen' => '/', 'pear/pear-propel-gen.bat' => '/', 'pear/pear-build.xml' => '/', 'pear/build.properties' => '/');
$options['dir_roles'] = array('projects' => 'data', 'test' => 'test', 'templates' => 'data', 'resources' => 'data');
$options['exceptions'] = array('pear/pear-propel-gen.bat' => 'script', 'pear/pear-propel-gen' => 'script', 'pear/pear-build.xml' => 'data', 'build.xml' => 'data', 'build-propel.xml' => 'data');
$pkg->setOptions($options);
}
开发者ID:sensorsix,项目名称:app,代码行数:27,代码来源:BuildPropelGenPEARPackageTask.php
示例9: parseFile
/**
*
*/
public function parseFile($xmlFile)
{
try {
$this->data = array();
try {
$fr = new FileReader($xmlFile);
} catch (Exception $e) {
$f = new PhingFile($xmlFile);
throw new BuildException("XML File not found: " . $f->getAbsolutePath());
}
$br = new BufferedReader($fr);
$this->parser = new ExpatParser($br);
$this->parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0);
$this->parser->setHandler($this);
try {
$this->parser->parse();
} catch (Exception $e) {
print $e->getMessage() . "\n";
$br->close();
}
$br->close();
} catch (Exception $e) {
print $e->getMessage() . "\n";
print $e->getTraceAsString();
}
return $this->data;
}
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:36,代码来源:XmlToData.php
示例10: __construct
/**
* Constructs a new ProjectConfigurator object
* This constructor is private. Use a static call to
* <code>configureProject</code> to configure a project.
*
* @param Project $project the Project instance this configurator should use
* @param PhingFile $buildFile the buildfile object the parser should use
*/
public function __construct(Project $project, PhingFile $buildFile)
{
$this->project = $project;
$this->buildFile = new PhingFile($buildFile->getAbsolutePath());
$this->buildFileParent = new PhingFile($this->buildFile->getParent());
$this->parseEndTarget = new Target();
}
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:15,代码来源:ProjectConfigurator.php
示例11: createDirectories
private function createDirectories($path)
{
$f = new PhingFile($path);
if (!$f->exists()) {
$f->mkdirs();
}
}
开发者ID:sensorsix,项目名称:app,代码行数:7,代码来源:ExtendedFileStream.php
示例12: setToDir
/**
* Sets output directory
* @param string $toDir
*/
public function setToDir($toDir)
{
if (!is_dir($toDir)) {
$toDir = new PhingFile($toDir);
$toDir->mkdirs();
}
$this->toDir = $toDir;
}
开发者ID:Ingewikkeld,项目名称:phing,代码行数:12,代码来源:AbstractPHPLocFormatter.php
示例13: testCorrectModeSet
public function testCorrectModeSet()
{
$this->executeTarget("test");
$dir = new PhingFile(PHING_TEST_BASE . "/etc/regression/745/testdir");
$mode = $dir->getMode() & 511;
$this->assertEquals($mode, 511);
$dir->delete(true);
}
开发者ID:laiello,项目名称:lion-framework,代码行数:8,代码来源:MkdirTaskModeTest.php
示例14: load
/**
* Load properties from a file.
*
* @param PhingFile $file
* @return void
* @throws IOException - if unable to read file.
*/
function load(PhingFile $file)
{
if ($file->canRead()) {
$this->parse($file->getPath(), false);
} else {
throw new IOException("Can not read file " . $file->getPath());
}
}
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:15,代码来源:Properties.php
示例15: copyFile
function copyFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false, $preserveLastModified = true, &$filterChains = null, Project $project)
{
// writes to tmp file first, then rename it to avoid file locking race
// conditions
$parent = $destFile->getParentFile();
$tmpFile = new PhingFile($parent, substr(md5(time()), 0, 8));
parent::copyFile($sourceFile, $tmpFile, $overwrite, $preserveLastModified, $filterChains, $project);
$tmpFile->renameTo($destFile);
}
开发者ID:hellogerard,项目名称:phing-things,代码行数:9,代码来源:ConsistentCopy.php
示例16: doWork
/**
* Copied from 'CopyTask.php'
*/
protected function doWork()
{
// These "slots" allow filters to retrieve information about the currently-being-process files
$fromSlot = $this->getRegisterSlot("currentFromFile");
$fromBasenameSlot = $this->getRegisterSlot("currentFromFile.basename");
$toSlot = $this->getRegisterSlot("currentToFile");
$toBasenameSlot = $this->getRegisterSlot("currentToFile.basename");
$mapSize = count($this->fileCopyMap);
$total = $mapSize;
if ($mapSize > 0) {
$this->log("Minifying " . $mapSize . " file" . ($mapSize === 1 ? '' : 's') . " to " . $this->destDir->getAbsolutePath());
// walks the map and actually copies the files
$count = 0;
foreach ($this->fileCopyMap as $from => $to) {
if ($from === $to) {
$this->log("Skipping self-copy of " . $from, $this->verbosity);
$total--;
continue;
}
$this->log("From " . $from . " to " . $to, $this->verbosity);
try {
// try to copy file
$fromFile = new PhingFile($from);
$toFile = new PhingFile($to);
$fromSlot->setValue($fromFile->getPath());
$fromBasenameSlot->setValue($fromFile->getName());
$toSlot->setValue($toFile->getPath());
$toBasenameSlot->setValue($toFile->getName());
$this->fileUtils->copyFile($fromFile, $toFile, $this->overwrite, $this->preserveLMT, $this->filterChains, $this->getProject());
// perform ''minification'' once all other things are done on it.
$this->minify($toFile);
$count++;
} catch (IOException $ioe) {
$this->log("Failed to minify " . $from . " to " . $to . ": " . $ioe->getMessage(), Project::MSG_ERR);
}
}
}
// handle empty dirs if appropriate
if ($this->includeEmpty) {
$destdirs = array_values($this->dirCopyMap);
$count = 0;
foreach ($destdirs as $destdir) {
$d = new PhingFile((string) $destdir);
if (!$d->exists()) {
if (!$d->mkdirs()) {
$this->log("Unable to create directory " . $d->__toString(), Project::MSG_ERR);
} else {
$count++;
}
}
}
if ($count > 0) {
$this->log("Copied " . $count . " empty director" . ($count == 1 ? "y" : "ies") . " to " . $this->destDir->getAbsolutePath());
}
}
}
开发者ID:jldupont,项目名称:jldupont.com,代码行数:59,代码来源:JsMinTask.php
示例17: listArchiveContent
/**
* List archive content
* @param PhingFile Zip file to list content
* @return array List of files inside $zipfile
*/
protected function listArchiveContent(PhingFile $zipfile)
{
$zip = new ZipArchive();
$zip->open($zipfile->getAbsolutePath());
$content = array();
for ($i = 0; $i < $zip->numFiles; $i++) {
$content[] = array('filename' => $zip->getNameIndex($i));
}
return $content;
}
开发者ID:Ingewikkeld,项目名称:phing,代码行数:15,代码来源:UnzipTask.php
示例18: testFlipFlopTarget
public function testFlipFlopTarget()
{
// calls target in main that depends on target in import that depends on
// target orverridden in main
$this->executeTarget("flipflop");
$f1 = new PhingFile(PHING_TEST_BASE . "/etc/tasks/importing.xml");
$f2 = new PhingFile(PHING_TEST_BASE . "/etc/tasks/imports/imported.xml");
$this->assertInLogs("This is " . $f1->getAbsolutePath() . " flop target.");
$this->assertInLogs("This is " . $f2->getAbsolutePath() . " flip target.");
$this->assertInLogs("This is " . $f1->getAbsolutePath() . " flipflop target.");
}
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:11,代码来源:ImportTaskTest.php
示例19: processClonesNew
/**
* Wrapper for PHPCPD 2.0
*
* @param CodeCloneMap $clones
* @param boolean $useFile
* @param PhingFile|null $outFile
*/
private function processClonesNew($clones, $useFile = false, $outFile = null)
{
if ($useFile) {
$resource = fopen($outFile->getPath(), "w");
} else {
$resource = fopen("php://output", "w");
}
$output = new \Symfony\Component\Console\Output\StreamOutput($resource);
$logger = new \SebastianBergmann\PHPCPD\Log\Text();
$logger->printResult($output, $clones);
}
开发者ID:Ingewikkeld,项目名称:phing,代码行数:18,代码来源:DefaultPHPCPDResultFormatter.php
示例20: evaluate
/**
* Evaluate the condition.
*/
public function evaluate()
{
foreach ($this->filelists as $filelist) {
$dir = $filelist->getDir($this->getProject());
foreach ($filelist->getFiles($this->getProject()) as $file) {
$file = new PhingFile($dir, $file);
if (!$file->exists()) {
return FALSE;
}
}
}
return TRUE;
}
开发者ID:michael-wojcik,项目名称:open_eggheads,代码行数:16,代码来源:AvailableFileListTask.php
注:本文中的PhingFile类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论