當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。