/** * Executes this task. */ public function main() { if ($this->property === null) { throw new BuildException('The property attribute must be specified'); } if ($this->path === null) { throw new BuildException('The path attribute must be specified'); } $check = new AgaviProjectFilesystemCheck(); $check->setAppDirectory($this->project->getProperty('project.directory.app')); $check->setPubDirectory($this->project->getProperty('project.directory.pub')); $check->setPath($this->path->getAbsolutePath()); if (!$check->check()) { throw new BuildException('The path attribute must be a valid project base directory'); } $modules = array(); foreach (new DirectoryIterator($this->path->getAbsolutePath() . DIRECTORY_SEPARATOR . $this->project->getProperty('project.directory.app.modules')) as $file) { if ($file->isDot()) { continue; } $check = new AgaviModuleFilesystemCheck(); $check->setConfigDirectory($this->project->getProperty('module.config.directory')); $check->setPath($file->getPathname()); if ($check->check()) { $modules[] = (string) $file; } } $list = new AgaviArraytostringTransform(); $list->setInput($modules); $list->setDelimiter(' '); $this->project->setUserProperty($this->property, $list->transform()); }
/** * Executes the task. */ public function main() { if ($this->property === null) { throw new BuildException('The property attribute must be specified'); } if ($this->path === null) { throw new BuildException('The path attribute must be specified'); } if ($this->ignoreIfSet && $this->project->getProperty($this->property) !== null) { return; } if (!$this->path->exists()) { throw new BuildException('The path ' . $this->path->getAbsolutePath() . ' does not exist'); } $this->path = $this->path->getAbsoluteFile(); if (!$this->path->isDirectory()) { $this->path = $this->path->getParentFile(); } /* Check if the current directory is a project directory. */ $check = new AgaviProjectFilesystemCheck(); $check->setAppDirectory($this->project->getProperty('project.directory.app')); $check->setPubDirectory($this->project->getProperty('project.directory.pub')); $check->setPath($this->path->getAbsolutePath()); if ($check->check()) { /* The current path is the project directory. */ $this->log('Project base directory: ' . $this->path->getPath()); $this->project->setUserProperty($this->property, $this->path->getAbsolutePath()); return; } /* Check if "app" or "pub" are in the current path. */ if (preg_match(sprintf('#^(.+?)/(?:%s|%s)(?:/|$)#', $this->project->getProperty('project.directory.app'), $this->project->getProperty('project.directory.pub')), $this->path->getPath(), $matches)) { $directory = new PhingFile($matches[1]); $check->setPath($directory->getAbsolutePath()); if ($check->check()) { $this->log('Project base directory: ' . $directory); $this->project->setUserProperty($this->property, $directory->getAbsolutePath()); return; } } /* Last chance: recurse upward and check for a project directory. */ $directory = $this->path; while (($directory = $directory->getParentFile()) !== null) { $check->setPath($directory->getAbsolutePath()); if ($check->check()) { $this->log('Project base directory: ' . $directory); $this->project->setUserProperty($this->property, $directory->getAbsolutePath()); return; } } }
/** * Executes this target. */ public function main() { if ($this->property === null) { throw new BuildException('The property attribute must be specified'); } if ($this->path === null) { throw new BuildException('The path attribute must be specified'); } $check = new AgaviProjectFilesystemCheck(); $check->setAppDirectory($this->project->getProperty('project.directory.app')); $check->setPubDirectory($this->project->getProperty('project.directory.pub')); $check->setPath($this->path->getAbsolutePath()); if ($check->check()) { $this->project->setUserProperty($this->property, $this->value); } else { $this->project->setUserProperty($this->property, null); } }
/** * Executes this task. */ public function main() { if ($this->path === null) { throw new BuildException('The path attribute must be specified'); } $check = new AgaviProjectFilesystemCheck(); $check->setAppDirectory($this->project->getProperty('project.directory.app')); $check->setPubDirectory($this->project->getProperty('project.directory.pub')); $check->setPath($this->path->getAbsolutePath()); if (!$check->check()) { throw new BuildException('The path attribute must be a valid project base directory'); } foreach (new DirectoryIterator($this->path->getAbsolutePath() . DIRECTORY_SEPARATOR . $this->project->getProperty('project.directory.app.modules')) as $file) { if ($file->isDot()) { continue; } $check = new AgaviModuleFilesystemCheck(); $check->setConfigDirectory($this->project->getProperty('module.config.directory')); $check->setPath($file->getPathname()); if ($check->check()) { $this->log((string) $file, Project::MSG_INFO); } } }