本文整理汇总了PHP中PhingFile::getParent方法的典型用法代码示例。如果您正苦于以下问题:PHP PhingFile::getParent方法的具体用法?PHP PhingFile::getParent怎么用?PHP PhingFile::getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhingFile
的用法示例。
在下文中一共展示了PhingFile::getParent方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: setOptions
private function setOptions($pkg)
{
$options = array();
$options['baseinstalldir'] = 'spindash';
$options['packagedirectory'] = $this->dir->getAbsolutePath();
$options['filelistgenerator'] = 'Fileset';
$options['phing_project'] = $this->getProject();
$options['phing_filesets'] = $this->filesets;
if (!is_null($this->packageFile)) {
$f = new PhingFile($this->packageFile->getAbsolutePath());
$options['packagefile'] = $f->getName();
$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);
}
$pkg->setOptions($options);
}
示例4: 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);
}
$pkg->setOptions($options);
}
示例5: _getParentFile
/**
* Helper to get the parent file for a given file.
*
* @param PhingFile $file
* @return PhingFile Parent file or null if none
*/
private function _getParentFile(PhingFile $file)
{
$filename = $file->getAbsolutePath();
$file = new PhingFile($filename);
$filename = $file->getParent();
return $filename === null ? null : new PhingFile($filename);
}
示例6: populateOptions
/**
* Adds the options that are set via attributes and the nested tags to the options array.
*/
private function populateOptions()
{
// These values could be overridden if explicitly defined using nested tags
$this->preparedOptions['package'] = $this->package;
$this->preparedOptions['packagedirectory'] = $this->dir->getAbsolutePath();
if ($this->packageFile !== null) {
// create one w/ full path
$f = new PhingFile($this->packageFile->getAbsolutePath());
$this->preparedOptions['packagefile'] = $f->getName();
// must end in trailing slash
$this->preparedOptions['outputdirectory'] = $f->getParent() . DIRECTORY_SEPARATOR;
$this->log("Creating package file: " . $f->__toString(), Project::MSG_INFO);
} else {
$this->log("Creating [default] package.xml file in base directory.", Project::MSG_INFO);
}
// converts option objects and mapping objects into
// key => value options that can be passed to PEAR_PackageFileManager
foreach ($this->options as $opt) {
$this->preparedOptions[$opt->getName()] = $opt->getValue();
//no arrays yet. preg_split('/\s*,\s*/', $opt->getValue());
}
foreach ($this->mappings as $map) {
$value = $map->getValue();
// getValue returns complex value
if ($map->getName() == 'deps') {
$value = $this->fixDeps($value);
}
$this->preparedOptions[$map->getName()] = $value;
}
}
示例7: main
/**
* Main method builds all the targets for a typical propel project.
*/
public function main()
{
// check to make sure task received all correct params
$this->validate();
$generatorConfig = $this->getGeneratorConfig();
// loading model from database
$this->log('Reading databases structure...');
$connections = $generatorConfig->getBuildConnections();
if (!$connections) {
throw new Exception('You must define database connection settings in a buildtime-conf.xml file to use diff');
}
$totalNbTables = 0;
$ad = new AppData();
foreach ($connections as $name => $params) {
$this->log(sprintf('Connecting to database "%s" using DSN "%s"', $name, $params['dsn']), Project::MSG_VERBOSE);
$pdo = $generatorConfig->getBuildPDO($name);
$database = new Database($name);
$platform = $generatorConfig->getConfiguredPlatform($pdo);
$database->setPlatform($platform);
$database->setDefaultIdMethod(IDMethod::NATIVE);
$parser = $generatorConfig->getConfiguredSchemaParser($pdo);
$nbTables = $parser->parse($database, $this);
$ad->addDatabase($database);
$totalNbTables += $nbTables;
$this->log(sprintf('%d tables imported from database "%s"', $nbTables, $name), Project::MSG_VERBOSE);
}
if ($totalNbTables) {
$this->log(sprintf('%d tables imported from databases.', $totalNbTables));
} else {
$this->log('Database is empty');
}
// loading model from XML
$this->packageObjectModel = true;
$appDatasFromXml = $this->getDataModels();
$appDataFromXml = array_pop($appDatasFromXml);
// comparing models
$this->log('Comparing models...');
$manager = new PropelMigrationManager();
$manager->setConnections($connections);
$manager->setMigrationDir($this->getOutputDirectory());
$migrationsUp = array();
$migrationsDown = array();
foreach ($ad->getDatabases() as $database) {
$name = $database->getName();
$this->log(sprintf('Comparing database "%s"', $name), Project::MSG_VERBOSE);
if (!$appDataFromXml->hasDatabase($name)) {
// FIXME: tables present in database but not in XML
continue;
}
$databaseDiff = PropelDatabaseComparator::computeDiff($database, $appDataFromXml->getDatabase($name), $this->isCaseInsensitive());
if (!$databaseDiff) {
$this->log(sprintf('Same XML and database structures for datasource "%s" - no diff to generate', $name), Project::MSG_VERBOSE);
continue;
}
$this->log(sprintf('Structure of database was modified in datasource "%s": %s', $name, $databaseDiff->getDescription()));
$platform = $generatorConfig->getConfiguredPlatform(null, $name);
$migrationsUp[$name] = $platform->getModifyDatabaseDDL($databaseDiff);
$migrationsDown[$name] = $platform->getModifyDatabaseDDL($databaseDiff->getReverseDiff());
}
if (!$migrationsUp) {
$this->log('Same XML and database structures for all datasource - no diff to generate');
return;
}
$timestamp = time();
$migrationFileName = $manager->getMigrationFileName($timestamp);
$migrationClassBody = $manager->getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp);
$_f = new PhingFile($this->getOutputDirectory(), $migrationFileName);
file_put_contents($_f->getAbsolutePath(), $migrationClassBody);
$this->log(sprintf('"%s" file successfully created in %s', $_f->getName(), $_f->getParent()));
if ($editorCmd = $this->getEditorCmd()) {
$this->log(sprintf('Using "%s" as text editor', $editorCmd));
shell_exec($editorCmd . ' ' . escapeshellarg($_f->getAbsolutePath()));
} else {
$this->log(' Please review the generated SQL statements, and add data migration code if necessary.');
$this->log(' Once the migration class is valid, call the "migrate" task to execute it.');
}
}
示例8: resolveFile
/**
* Interpret the filename as a file relative to the given file -
* unless the filename already represents an absolute filename.
*
* @param $file the "reference" file for relative paths. This
* instance must be an absolute file and must not contain
* ./ or ../ sequences (same for \ instead of /).
* @param $filename a file name
*
* @return PhingFile A PhingFile object pointing to an absolute file that doesn't contain ./ or ../ sequences
* and uses the correct separator for the current platform.
*/
function resolveFile($file, $filename)
{
// remove this and use the static class constant File::seperator
// as soon as ZE2 is ready
$fs = FileSystem::getFileSystem();
$filename = str_replace('/', $fs->getSeparator(), str_replace('\\', $fs->getSeparator(), $filename));
// deal with absolute files
if (StringHelper::startsWith($fs->getSeparator(), $filename) || strlen($filename) >= 2 && Character::isLetter($filename[0]) && $filename[1] === ':') {
return new PhingFile($this->normalize($filename));
}
if (strlen($filename) >= 2 && Character::isLetter($filename[0]) && $filename[1] === ':') {
return new PhingFile($this->normalize($filename));
}
$helpFile = new PhingFile($file->getAbsolutePath());
$tok = strtok($filename, $fs->getSeparator());
while ($tok !== false) {
$part = $tok;
if ($part === '..') {
$parentFile = $helpFile->getParent();
if ($parentFile === null) {
$msg = "The file or path you specified ({$filename}) is invalid relative to " . $file->getPath();
throw new IOException($msg);
}
$helpFile = new PhingFile($parentFile);
} else {
if ($part === '.') {
// Do nothing here
} else {
$helpFile = new PhingFile($helpFile, $part);
}
}
$tok = strtok($fs->getSeparator());
}
return new PhingFile($helpFile->getAbsolutePath());
}
示例9: checkAccess
/**
* Check whether the file or directory denoted by the given abstract
* pathname may be accessed by this process. If the second argument is
* false, then a check for read access is made; if the second
* argument is true, then a check for write (not read-write)
* access is made. Return false if access is denied or an I/O error
* occurs.
*/
function checkAccess(PhingFile $f, $write = false)
{
// we clear stat cache, its expensive to look up from scratch,
// but we need to be sure
@clearstatcache();
// Shouldn't this be $f->GetAbsolutePath() ?
// And why doesn't GetAbsolutePath() work?
$strPath = (string) $f->getPath();
// FIXME
// if file object does denote a file that yet not existst
// path rights are checked
if (!@file_exists($strPath) && !is_dir($strPath)) {
$strPath = $f->getParent();
if ($strPath === null || !is_dir($strPath)) {
$strPath = Phing::getProperty("user.dir");
}
//$strPath = dirname($strPath);
}
if (!$write) {
return (bool) @is_readable($strPath);
} else {
return (bool) @is_writable($strPath);
}
}
示例10: _checkFile1
/**
* @param PhingFile $file
* @return bool
* @throws IOException
*/
private function _checkFile1(PhingFile $file)
{
// Resolve symbolic links
if ($this->followSymlinks && $file->isLink()) {
$linkTarget = new PhingFile($file->getLinkTarget());
if ($linkTarget->isAbsolute()) {
$file = $linkTarget;
} else {
$fs = FileSystem::getFileSystem();
$file = new PhingFile($fs->resolve($fs->normalize($file->getParent()), $fs->normalize($file->getLinkTarget())));
}
}
if ($this->type !== null) {
if ($this->type === "dir") {
return $file->isDirectory();
} else {
if ($this->type === "file") {
return $file->isFile();
}
}
}
return $file->exists();
}
示例11: startElement
/**
* Handles opening elements of the xml file.
*
* @param string $uri
* @param string $localName The local name (without prefix), or the empty string if
* Namespace processing is not being performed.
* @param string $rawName The qualified name (with prefix), or the empty string if
* qualified names are not available.
* @param string $attributes The specified or defaulted attributes
*/
public function startElement($name, $attributes)
{
try {
$parentTag = $this->peekCurrentSchemaTag();
if ($parentTag === false) {
switch ($name) {
case "database":
if ($this->isExternalSchema()) {
$this->currentPackage = @$attributes["package"];
if ($this->currentPackage === null) {
$this->currentPackage = $this->defaultPackage;
}
} else {
$this->currDB = $this->app->addDatabase($attributes);
}
break;
default:
$this->_throwInvalidTagException($name);
}
} elseif ($parentTag == "database") {
switch ($name) {
case "external-schema":
$xmlFile = @$attributes["filename"];
//"referenceOnly" attribute is valid in the main schema XML file only,
//and it's ingnored in the nested external-schemas
if (!$this->isExternalSchema()) {
$isForRefOnly = @$attributes["referenceOnly"];
$this->isForReferenceOnly = $isForRefOnly !== null ? strtolower($isForRefOnly) === "true" : true;
// defaults to TRUE
}
if ($xmlFile[0] != '/') {
$f = new PhingFile($this->currentXmlFile);
$xf = new PhingFile($f->getParent(), $xmlFile);
$xmlFile = $xf->getPath();
}
$this->parseFile($xmlFile);
break;
case "domain":
$this->currDB->addDomain($attributes);
break;
case "table":
$this->currTable = $this->currDB->addTable($attributes);
if ($this->isExternalSchema()) {
$this->currTable->setForReferenceOnly($this->isForReferenceOnly);
$this->currTable->setPackage($this->currentPackage);
}
break;
case "vendor":
$this->currVendorObject = $this->currDB->addVendorInfo($attributes);
break;
case "behavior":
$this->currBehavior = $this->currDB->addBehavior($attributes);
break;
default:
$this->_throwInvalidTagException($name);
}
} elseif ($parentTag == "table") {
switch ($name) {
case "column":
$this->currColumn = $this->currTable->addColumn($attributes);
break;
case "foreign-key":
$this->currFK = $this->currTable->addForeignKey($attributes);
break;
case "index":
$this->currIndex = $this->currTable->addIndex($attributes);
break;
case "unique":
$this->currUnique = $this->currTable->addUnique($attributes);
break;
case "vendor":
$this->currVendorObject = $this->currTable->addVendorInfo($attributes);
break;
case "validator":
$this->currValidator = $this->currTable->addValidator($attributes);
break;
case "id-method-parameter":
$this->currTable->addIdMethodParameter($attributes);
break;
case "behavior":
$this->currBehavior = $this->currTable->addBehavior($attributes);
break;
default:
$this->_throwInvalidTagException($name);
}
} elseif ($parentTag == "column") {
switch ($name) {
case "inheritance":
$this->currColumn->addInheritance($attributes);
break;
//.........这里部分代码省略.........
示例12: PhingFile
/**
* Helper to get the parent file for a given file.
*
* @param PhingFile $file
* @return PhingFile Parent file or null if none
*/
function _getParentFile(PhingFile $file)
{
$filename = $file->getAbsolutePath();
$file = new PhingFile($filename);
$filename = $file->getParent();
if ($filename !== null && self::$msgOutputLevel >= PROJECT_MSG_VERBOSE) {
print "Searching in {$filename}\n";
}
return $filename === null ? null : new PhingFile($filename);
}
示例13: _getParentFile
/**
* Helper to get the parent file for a given file.
*
* @param PhingFile $file
* @return PhingFile Parent file or null if none
*/
private function _getParentFile(PhingFile $file)
{
$filename = $file->getAbsolutePath();
$file = new PhingFile($filename);
$filename = $file->getParent();
if ($filename !== null && self::$msgOutputLevel >= Project::MSG_VERBOSE) {
self::$out->write("Searching in {$filename}" . self::getProperty("line.separator"));
}
return $filename === null ? null : new PhingFile($filename);
}