本文整理汇总了PHP中FileSet::setDir方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSet::setDir方法的具体用法?PHP FileSet::setDir怎么用?PHP FileSet::setDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSet
的用法示例。
在下文中一共展示了FileSet::setDir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: schemaConfiguration
protected function schemaConfiguration(Task $task)
{
// Adds schema(s) to task
foreach ($this->schemas as $pair) {
$fileSet = new FileSet();
$fileSet->setDir($pair[0]);
$fileSet->setIncludes($pair[1]);
$task->addSchemaFileset($fileSet);
}
// Sets up output dir, for class, SQL or conf output
$task->setOutputDirectory(new PhingFile($this->outputDir));
}
示例2: main
/**
* Reads the corresponding actions and templates of the cronk (if any) from cronk.xml
* and creates two references "cronkTemplate" and "cronkAction" which can be used to access these files
*/
public function main()
{
$templates = array();
$actionPath = "";
$action = null;
$module = null;
$cronkName = $this->project->getUserProperty("cronkName");
// Setup and load the DOM of the cronk
$DOM = new DOMDocument("1.0", "UTF-8");
$DOM->load($this->getFile());
$DOMSearcher = new DOMXPath($DOM);
$DOMSearcher->registerNamespace("default", "http://agavi.org/agavi/1.0/config");
$DOMSearcher->registerNamespace("ae", "http://agavi.org/agavi/config/global/envelope/1.0");
$cronkTemplates = $DOMSearcher->query("//ae:parameter[@name='" . $cronkName . "']//ae:parameter[@name='template']");
if ($cronkTemplates->length > 0) {
foreach ($cronkTemplates as $template) {
$templates[] = $template->nodeValue;
}
}
// fetch action and module
$action = $DOMSearcher->query("//ae:parameter[@name='" . $cronkName . "']//ae:parameter[@name='action']")->item(0);
$module = $DOMSearcher->query("//ae:parameter[@name='" . $cronkName . "']//ae:parameter[@name='module']")->item(0);
$actionName = str_replace(".", "/", $action->nodeValue);
// add agavi action,validation, view and templates
$cronkFS = new FileSet();
$cronkFS->setDir($this->project->getUserProperty("PATH_Icinga") . "/app/modules/" . $module->nodeValue);
$cronkIncludes = "actions/" . $actionName . "Action.class.php";
$cronkIncludes .= ",templates/" . $actionName . "*.class.php";
$cronkIncludes .= ",validate/" . $actionName . ".xml";
$cronkIncludes .= ",views/" . $actionName . "*.class.php";
$cronkFS->setIncludes($cronkIncludes);
// add templates
$templateFs = new FileSet();
$templateFs->setDir($this->project->getUserProperty("PATH_Icinga") . "/app/modules/Cronks/data/xml/");
$includes = "";
$first = true;
foreach ($templates as $template) {
$includes .= ($first ? '' : ',') . $template . ".xml";
}
// export to phing
$templateFs->setIncludes($includes);
$this->project->addReference("cronkTemplates", $templateFs);
$this->project->addReference("cronkAction", $cronkFS);
}
示例3: getDirectoryScanner
/**
* Returns the directory scanner needed to access the files to process.
* @return DirectoryScanner
*/
protected function getDirectoryScanner(PhingFile $baseDir)
{
$this->fileset->setDir($baseDir);
$this->fileset->setDefaultexcludes($this->useDefaultExcludes);
return $this->fileset->getDirectoryScanner($this->project);
}
示例4: main
/**
* {@inheritdoc}
*
* @throws BuildException
* @throws IOException
*/
public function main()
{
if ($this->dir == null) {
throw new BuildException("missing dir");
}
if ($this->name == null) {
throw new BuildException("missing name");
}
if ($this->pathRefId == null) {
throw new BuildException("missing pathrefid");
}
if (!$this->dir->isDirectory()) {
throw new BuildException($this->dir->toString() . " is not a directory");
}
$path = $this->getProject()->getReference($this->pathRefId);
if ($path == null) {
throw new BuildException("Unknown reference " . $this->pathRefId);
}
if (!$path instanceof Path) {
throw new BuildException($this->pathRefId . " is not a path");
}
$sources = $path->listPaths();
$fileSet = new FileSet();
$fileSet->setProject($this->getProject());
$fileSet->setDir($this->dir);
$fileUtils = new FileUtils();
$dirNormal = $fileUtils->normalize($this->dir->getAbsolutePath());
$dirNormal = rtrim($dirNormal, PhingFile::$separator) . PhingFile::$separator;
$atLeastOne = false;
for ($i = 0; $i < count($sources); ++$i) {
$sourceFile = new PhingFile($sources[$i]);
if (!$sourceFile->exists()) {
continue;
}
$includePattern = $this->getIncludePattern($dirNormal, $sourceFile);
if ($includePattern === false && !$this->ignoreNonRelative) {
throw new BuildException($sources[$i] . " is not relative to " . $this->dir->getAbsolutePath());
}
if ($includePattern === false) {
continue;
}
$fileSet->createInclude()->setName($includePattern);
$atLeastOne = true;
}
if (!$atLeastOne) {
$fileSet->createInclude()->setName("a:b:c:d//THis si &&& not a file !!! ");
}
$this->getProject()->addReference($this->name, $fileSet);
}
示例5: 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 ($this->baseDir !== null) {
if (!$this->baseDir->exists()) {
throw new BuildException("basedir does not exist!", $this->getLocation());
}
// add the main fileset to the list of filesets to process.
$mainFileSet = new FileSet($this->fileset);
$mainFileSet->setDir($this->baseDir);
$this->filesets[] = $mainFileSet;
}
if (empty($this->filesets)) {
throw new BuildException("You must supply either a basedir " . "attribute or some nested filesets.", $this->getLocation());
}
// check if zip is out of date with respect to each
// fileset
$upToDate = true;
foreach ($this->filesets as $fs) {
$ds = $fs->getDirectoryScanner($this->project);
$files = $ds->getIncludedFiles();
if (!$this->archiveIsUpToDate($files, $fs->getDir($this->project))) {
$upToDate = false;
}
for ($i = 0, $fcount = count($files); $i < $fcount; $i++) {
if ($this->zipFile->equals(new PhingFile($fs->getDir($this->project), $files[$i]))) {
throw new BuildException("A zip file cannot include itself", $this->getLocation());
}
}
}
if ($upToDate) {
$this->log("Nothing to do: " . $this->zipFile->__toString() . " is up to date.", PROJECT_MSG_INFO);
return;
}
$this->log("Building zip: " . $this->zipFile->__toString(), PROJECT_MSG_INFO);
$zip = new Archive_Zip($this->zipFile->getAbsolutePath());
foreach ($this->filesets as $fs) {
$ds = $fs->getDirectoryScanner($this->project);
$files = $ds->getIncludedFiles();
// FIXME
// Current model is only adding directories implicitly. This
// won't add any empty directories. Perhaps modify FileSet::getFiles()
// to also include empty directories. Not high priority, since non-inclusion
// of empty dirs is probably not unexpected behavior for ZipTask.
$fsBasedir = $fs->getDir($this->project);
$filesToZip = array();
for ($i = 0, $fcount = count($files); $i < $fcount; $i++) {
$f = new PhingFile($fsBasedir, $files[$i]);
$filesToZip[] = $f->getAbsolutePath();
}
$zip->add($filesToZip, array('remove_path' => $fsBasedir->getCanonicalPath()));
}
} catch (IOException $ioe) {
$msg = "Problem creating ZIP: " . $ioe->getMessage();
$this->filesets = $savedFileSets;
throw new BuildException($msg, $ioe, $this->getLocation());
}
$this->filesets = $savedFileSets;
}
示例6: getSQLDescriptors
/**
* Returns a file descriptior with the sql files
* @return FileSet
*/
protected function getSQLDescriptors()
{
$xml = $this->getManifest()->getManifestAsSimpleXML();
$db = $xml->Database;
$sqlList = new FileSet();
$sqlList->setDir($this->project->getUserProperty("PATH_Icinga"));
$includes = null;
if (!$db->SQLRoutines) {
$sqlList->setExcludes("**");
}
return $sqlList;
foreach ($db->SQLRoutines->children() as $type => $content) {
$type = (string) $type;
$content = $this->getPath((string) $content);
switch ($type) {
case 'File':
if ($includes != "") {
$includes .= ",";
}
$includes .= $content;
break;
case 'Folder':
if ($includes != "") {
$includes .= ",";
}
$includes .= $content . "/**";
break;
}
}
$sqlList->setIncludes($includes);
return $sqlList;
}