本文整理汇总了PHP中PhingFile::getAbsolutePath方法的典型用法代码示例。如果您正苦于以下问题:PHP PhingFile::getAbsolutePath方法的具体用法?PHP PhingFile::getAbsolutePath怎么用?PHP PhingFile::getAbsolutePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhingFile
的用法示例。
在下文中一共展示了PhingFile::getAbsolutePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doApply
protected function doApply()
{
$dataDir = $this->dataDir->getAbsolutePath();
$htmlDir = $this->htmlDir->getAbsolutePath();
define('HTML_REALDIR', rtrim(realpath($htmlDir), '/\\') . '/');
require_once HTML_REALDIR . '/define.php';
require_once HTML_REALDIR . HTML2DATA_DIR . '/require_base.php';
$query = SC_Query_Ex::getSingletonInstance();
$storage = new Zeclib_DefaultMigrationStorage($query, $this->system);
$storage->versionTable = $this->versionTable;
$storage->containerDirectories[] = $this->containerDir->getPath();
$migrator = new Zeclib_Migrator($storage, $query);
$migrator->logger = new Zeclib_Phing_TaskMigrationLogger($this);
$migrations = array();
$versions = preg_split('/[,\\s]+/', $this->version, 0, PREG_SPLIT_NO_EMPTY);
foreach ($versions as $version) {
try {
$migrations[] = $migrator->loadMigration($version);
} catch (Zeclib_MigrationException $e) {
$message = $e->getMessage();
$this->log($message, Zeclib_MigrationLogger::TYPE_WARNING);
}
}
$num = $migrator->apply($migrations);
$this->log(sprintf('%d migrations are applied.', $num));
}
示例2: 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;
}
示例3: main
/**
* do the work
* @throws BuildException
*/
public function main()
{
$this->validateAttributes();
$filesToExtract = array();
if ($this->file !== null) {
if (!$this->isDestinationUpToDate($this->file)) {
$filesToExtract[] = $this->file;
} else {
$this->log('Nothing to do: ' . $this->todir->getAbsolutePath() . ' is up to date for ' . $this->file->getCanonicalPath(), Project::MSG_INFO);
}
}
foreach ($this->filesets as $compressedArchiveFileset) {
$compressedArchiveDirScanner = $compressedArchiveFileset->getDirectoryScanner($this->project);
$compressedArchiveFiles = $compressedArchiveDirScanner->getIncludedFiles();
$compressedArchiveDir = $compressedArchiveFileset->getDir($this->project);
foreach ($compressedArchiveFiles as $compressedArchiveFilePath) {
$compressedArchiveFile = new PhingFile($compressedArchiveDir, $compressedArchiveFilePath);
if ($compressedArchiveFile->isDirectory()) {
throw new BuildException($compressedArchiveFile->getAbsolutePath() . ' compressed archive cannot be a directory.');
}
if (!$this->isDestinationUpToDate($compressedArchiveFile)) {
$filesToExtract[] = $compressedArchiveFile;
} else {
$this->log('Nothing to do: ' . $this->todir->getAbsolutePath() . ' is up to date for ' . $compressedArchiveFile->getCanonicalPath(), Project::MSG_INFO);
}
}
}
foreach ($filesToExtract as $compressedArchiveFile) {
$this->extractArchive($compressedArchiveFile);
}
}
示例4: 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();
}
示例5: main
public function main()
{
$plugin = $this->plugin->getAbsolutePath();
$infoFile = $plugin . '/' . self::INFO_FILE;
if (!file_exists($infoFile)) {
$message = sprintf('Unable to read plugin_info.php file at "%s"', $plugin);
throw new BuildException($message);
}
require_once $infoFile;
$class = new ReflectionClass('plugin_info');
try {
$value = $class->getStaticPropertyValue($this->key);
} catch (Exception $e) {
$message = sprintf('Unable to read property with "%s"', $this->key);
throw new BuildException($message, $e);
}
if (!is_string($value) && !is_int($value) && !is_float($value)) {
$value = json_encode($value);
}
if ($this->to != '') {
$this->project->setProperty($this->to, $value);
} else {
$this->log($value);
}
}
示例6: destroyDatabase
protected function destroyDatabase()
{
$dataDir = $this->dataDir->getAbsolutePath();
$htmlDir = $this->htmlDir->getAbsolutePath();
define('HTML_REALDIR', rtrim(realpath($htmlDir), '/\\') . '/');
require_once HTML_REALDIR . '/define.php';
require_once HTML_REALDIR . HTML2DATA_DIR . '/require_base.php';
$query = SC_Query_Ex::getSingletonInstance();
$mdb2 = $query->conn;
$mdb2->loadModule('Manager');
$result = $mdb2->dropTable($this->versionTable);
if (PEAR::isError($result)) {
throw new BuildException($result->getMessage());
}
}
示例7: __construct
/**
* Construct a new FileInputStream.
*
* @param PhingFile|string $file Path to the file
* @param boolean $append Whether to append (ignored)
* @throws Exception - if invalid argument specified.
* @throws IOException - if unable to open file.
*/
public function __construct($file, $append = false)
{
if ($file instanceof PhingFile) {
$this->file = $file;
} elseif (is_string($file)) {
$this->file = new PhingFile($file);
} else {
throw new Exception("Invalid argument type for \$file.");
}
$stream = @fopen($this->file->getAbsolutePath(), "rb");
if ($stream === false) {
throw new IOException("Unable to open " . $this->file->__toString() . " for reading: " . $php_errormsg);
}
parent::__construct($stream);
}
示例8: __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();
}
示例9: 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).
*/
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;
}
示例10: archiveIsUpToDate
/**
* @param array $files array of filenames
* @param PhingFile $dir
* @return boolean
*/
protected function archiveIsUpToDate($files, $dir)
{
$sfs = new SourceFileScanner($this);
$mm = new MergeMapper();
$mm->setTo($this->zipFile->getAbsolutePath());
return count($sfs->restrict($files, $dir, null, $mm)) == 0;
}
示例11: 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;
}
示例12: 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;
}
示例13: checkFileExists
public function checkFileExists()
{
//Get the correct path to asset
switch ($this->type) {
case Asset::ASSET_TYPE_CSS:
$this->assetFolder = $this->paths['css'];
break;
case Asset::ASSET_TYPE_JS:
$this->assetFolder = $this->paths['js'];
break;
case Asset::ASSET_TYPE_IMAGE:
$this->assetFolder = $this->paths['images'];
break;
default:
$folder = '';
}
//Path to file
$file = new PhingFile($this->assetsDir . '/' . $this->assetFolder . $this->file);
//Check file exists
if (!$file->exists()) {
throw new BuildException("Unable to find asset file: " . $file->getAbsolutePath());
}
//Check we can read it
if (!$file->canRead()) {
throw IOException("Unable to read asset file: " . $file->getPath());
}
return $file;
}
示例14: main
/**
* do the work
* @throws BuildException
*/
public function main()
{
if ($this->zipFile === null) {
throw new BuildException("zipFile attribute must be set!", $this->getLocation());
}
if ($this->zipFile->exists() && $this->zipFile->isDirectory()) {
throw new BuildException("zipFile is a directory!", $this->getLocation());
}
if ($this->zipFile->exists() && !$this->zipFile->canWrite()) {
throw new BuildException("Can not write to the specified zipFile!", $this->getLocation());
}
// shouldn't need to clone, since the entries in filesets
// themselves won't be modified -- only elements will be added
$savedFileSets = $this->filesets;
try {
if (empty($this->filesets)) {
throw new BuildException("You must supply some nested filesets.", $this->getLocation());
}
$this->log("Building ZIP: " . $this->zipFile->__toString(), Project::MSG_INFO);
$zip = new PclZip($this->zipFile->getAbsolutePath());
if ($zip->errorCode() != 1) {
throw new Exception("PclZip::open() failed: " . $zip->errorInfo());
}
foreach ($this->filesets as $fs) {
$files = $fs->getFiles($this->project, $this->includeEmpty);
$fsBasedir = null != $this->baseDir ? $this->baseDir : $fs->getDir($this->project);
$filesToZip = array();
for ($i = 0, $fcount = count($files); $i < $fcount; $i++) {
$f = new PhingFile($fsBasedir, $files[$i]);
//$filesToZip[] = realpath($f->getPath());
$fileAbsolutePath = $f->getPath();
$fileDir = rtrim(dirname($fileAbsolutePath), '/\\');
$fileBase = basename($fileAbsolutePath);
if (substr($fileDir, -4) == '.svn') {
continue;
}
if ($fileBase == '.svn') {
continue;
}
if (substr(rtrim($fileAbsolutePath, '/\\'), -4) == '.svn') {
continue;
}
//echo "\t\t$fileAbsolutePath\n";
$filesToZip[] = $f->getPath();
}
/*
$zip->add($filesToZip,
PCLZIP_OPT_ADD_PATH, is_null($this->prefix) ? '' : $this->prefix ,
PCLZIP_OPT_REMOVE_PATH, realpath($fsBasedir->getPath()) );
*/
$zip->add($filesToZip, PCLZIP_OPT_ADD_PATH, is_null($this->prefix) ? '' : $this->prefix, PCLZIP_OPT_REMOVE_PATH, $fsBasedir->getPath());
}
} catch (IOException $ioe) {
$msg = "Problem creating ZIP: " . $ioe->getMessage();
$this->filesets = $savedFileSets;
throw new BuildException($msg, $ioe, $this->getLocation());
}
$this->filesets = $savedFileSets;
}
示例15: run
/**
* Runs phpDocumentor 2
*/
public function run()
{
$this->initializePhpDocumentor();
$cache = $this->app['descriptor.cache'];
$cache->getOptions()->setCacheDir($this->destDir->getAbsolutePath());
$this->parseFiles();
$this->project->log("Transforming...", Project::MSG_VERBOSE);
$this->transformFiles();
}