Example #1
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());
 }
Example #3
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 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>.*?)')) . '$#';
     $actions = array();
     $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)) {
             $actions[] = str_replace(DIRECTORY_SEPARATOR, '.', $matches['action_name']);
         }
     }
     $list = new AgaviArraytostringTransform();
     $list->setInput($actions);
     $list->setDelimiter(' ');
     $this->project->setUserProperty($this->property, $list->transform());
 }