本文整理汇总了PHP中PhingFile类的典型用法代码示例。如果您正苦于以下问题:PHP PhingFile类的具体用法?PHP PhingFile怎么用?PHP PhingFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhingFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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();
}
示例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");
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例11: createDirectories
private function createDirectories($path)
{
$f = new PhingFile($path);
if (!$f->exists()) {
$f->mkdirs();
}
}
示例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;
}
示例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);
}
示例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());
}
}
示例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);
}