Example #1
1
 /**
  * Executes this task.
  */
 public function main()
 {
     if ($this->path === null) {
         throw new BuildException('The path attribute must be specified');
     }
     $check = new AgaviModuleFilesystemCheck();
     $check->setConfigDirectory($this->project->getProperty('module.config.directory'));
     $check->setPath($this->path->getAbsolutePath());
     if (!$check->check()) {
         throw new BuildException('The path attribute must be a valid module base directory');
     }
     /* We don't know whether the module is configured or not here, so load the
      * values we want properly. */
     $this->tryLoadAgavi();
     $this->tryBootstrapAgavi();
     require_once AgaviConfigCache::checkConfig(sprintf('%s/%s/module.xml', $this->path->getAbsolutePath(), (string) $this->project->getProperty('module.config.directory')));
     $actionPath = AgaviToolkit::expandVariables(AgaviToolkit::expandDirectives(AgaviConfig::get(sprintf('modules.%s.agavi.action.path', strtolower($this->path->getName())), '%core.module_dir%/${moduleName}/actions/${actionName}Action.class.php')), array('moduleName' => $this->path->getName()));
     $pattern = '#^' . AgaviToolkit::expandVariables(str_replace('\\$\\{actionName\\}', '${actionName}', preg_quote($actionPath, '#')), array('actionName' => '(?P<action_name>.*?)')) . '$#';
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path->getAbsolutePath()));
     for (; $iterator->valid(); $iterator->next()) {
         $rdi = $iterator->getInnerIterator();
         if ($rdi->isDot() || !$rdi->isFile()) {
             continue;
         }
         $file = $rdi->getPathname();
         if (preg_match($pattern, $file, $matches)) {
             $this->log(str_replace(DIRECTORY_SEPARATOR, '.', $matches['action_name']));
         }
     }
 }
Example #2
0
 /**
  * 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 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 AgaviModuleFilesystemCheck();
     $check->setConfigDirectory($this->project->getProperty('module.directory.config'));
     $check->setPath($this->path->getAbsolutePath());
     if (!$check->check()) {
         throw new BuildException('The path attribute must be a valid module base directory');
     }
     $actions = array();
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path->getAbsolutePath() . DIRECTORY_SEPARATOR . $this->project->getProperty('module.directory.actions')));
     for (; $iterator->valid(); $iterator->next()) {
         $rdi = $iterator->getInnerIterator();
         if ($rdi->isDot() || !$rdi->isFile()) {
             continue;
         }
         $file = $rdi->getSubpathname();
         if (preg_match('#Action\\.class\\.php$#', $file)) {
             $actions[] = str_replace(DIRECTORY_SEPARATOR, '.', substr($file, 0, -16));
         }
     }
     $list = new AgaviArraytostringTransform();
     $list->setInput($actions);
     $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 AgaviModuleFilesystemCheck();
     $check->setConfigDirectory($this->project->getProperty('module.directory.config'));
     $check->setPath($this->path->getAbsolutePath());
     if ($check->check()) {
         /* The current path is the project directory. */
         $this->log('Module base directory: ' . $this->path);
         $this->project->setUserProperty($this->property, $this->path->getName());
         return;
     }
     /* Check if "actions", "views", "templates", or "config" are in the current path. */
     if (preg_match(sprintf('#^(.+?)/(?:%s|%s|%s|%s)(?:/|$)#', $this->project->getProperty('module.directory.actions'), $this->project->getProperty('module.directory.views'), $this->project->getProperty('module.directory.templates'), $this->project->getProperty('module.directory.config')), $this->path->getPath(), $matches)) {
         $directory = new PhingFile($matches[1]);
         $check->setPath($directory->getAbsolutePath());
         if ($check->check()) {
             $this->log('Module base directory: ' . $directory);
             $this->project->setUserProperty($this->property, $directory->getName());
             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('Module base directory: ' . $directory);
             $this->project->setUserProperty($this->property, $directory->getName());
             return;
         }
     }
 }
Example #5
0
 /**
  * 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 AgaviModuleFilesystemCheck();
     $check->setConfigDirectory($this->project->getProperty('module.config.directory'));
     $check->setPath($this->path->getAbsolutePath());
     if ($check->check()) {
         $this->project->setUserProperty($this->property, $this->value);
     } else {
         $this->project->setUserProperty($this->property, null);
     }
 }
Example #6
0
 /**
  * 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 AgaviModuleFilesystemCheck();
     $check->setConfigDirectory($this->project->getProperty('module.config.directory'));
     $check->setPath($this->path->getAbsolutePath());
     if ($check->check()) {
         /* The current path is the project directory. */
         $this->log('Module base directory: ' . $this->path);
         $this->project->setUserProperty($this->property, $this->path->getName());
         return;
     }
     $check->setPath($this->path->getAbsolutePath());
     if ($check->check()) {
         $this->log('Module base directory: ' . $directory);
         $this->project->setUserProperty($this->property, $directory->getName());
         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('Module base directory: ' . $directory);
             $this->project->setUserProperty($this->property, $directory->getName());
             return;
         }
     }
 }
Example #7
0
 /**
  * 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);
         }
     }
 }