当前位置: 首页>>代码示例>>PHP>>正文


PHP PhingFile类代码示例

本文整理汇总了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);
 }
开发者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


注:本文中的PhingFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。