Changeset 2786

Show
Ignore:
Timestamp:
09/04/08 15:54:39 (4 months ago)
Author:
david
Message:

Allow customization of the way Actions, Views etc. are laid out in the filesystem, closes #668

Location:
branches/1.0
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/CHANGELOG

    r2782 r2786  
    55-------------------------------- 
    66 
     7ADD: Allow customization of the way Actions, Views etc. are laid out in the filesystem (#668) (David) 
    78ADD: AgaviXmlConfigDomElement::hasAgaviParameters() (#841) (David) 
    89 
  • branches/1.0/RELEASE_NOTES

    r2784 r2786  
    3333%core.app_dir%/modules/Default/actions/Foo_BarAction.class.php is class Default_Foo_BarAction 
    3434The legacy naming schemes (leaving out module name for Actions, Views and non-global Models; leaving out sub-notation paths except the last one) are not supported anymore. 
     35 
     36Finally, you can now define the filesystem structure of the following elements on a per-module basis: 
     37- Actions 
     38- Caching XML configs 
     39- Validation XML configs 
     40- Views 
     41You can also customize these aspects: 
     42- Default template "directory" part 
     43- View shortname resolution ("Success" => "Default_Sub_MarineSuccess") 
     44This allows you to put all the files for a feature into a single subdirectory, instead of having the separate files cluttered over action/, template/, view/ etc. subfolders inside the module directory. 
     45Ticket #668 has more details an an example. 
    3546 
    3647Project development environment 
  • branches/1.0/src/controller/AgaviController.class.php

    r2782 r2786  
    288288   */ 
    289289  public function checkActionFile($moduleName, $actionName) 
    290   {    
     290  { 
     291    $this->initializeModule($moduleName); 
    291292    $actionName = AgaviToolkit::canonicalName($actionName); 
    292     $file = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/actions/' . $actionName . 'Action.class.php'; 
     293    $file = AgaviToolkit::expandVariables( 
     294      AgaviToolkit::expandDirectives( 
     295        AgaviConfig::get( 
     296          sprintf('modules.%s.agavi.action.path', strtolower($moduleName)), 
     297          '%core.module_dir%/${moduleName}/actions/${actionName}Action.class.php' 
     298        ) 
     299      ), 
     300      array( 
     301        'moduleName' => $moduleName, 
     302        'actionName' => $actionName, 
     303      ) 
     304    ); 
    293305    if(is_readable($file) && substr($actionName, 0, 1) !== '/') { 
    294306      return $file; 
     
    368380   */ 
    369381  public function checkViewFile($moduleName, $viewName) 
    370   {  
     382  { 
     383    $this->initializeModule($moduleName); 
    371384    $viewName = AgaviToolkit::canonicalName($viewName); 
    372     $file = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/views/' . $viewName . 'View.class.php'; 
     385    $file = AgaviToolkit::expandVariables( 
     386      AgaviToolkit::expandDirectives( 
     387        AgaviConfig::get( 
     388          sprintf('modules.%s.agavi.view.path', strtolower($moduleName)), 
     389          '%core.module_dir%/${moduleName}/views/${viewName}View.class.php' 
     390        ) 
     391      ), 
     392      array( 
     393        'moduleName' => $moduleName, 
     394        'viewName' => $viewName, 
     395      ) 
     396    ); 
    373397    if(is_readable($file) && substr($viewName, 0, 1) !== '/') { 
    374398      return $file; 
  • branches/1.0/src/filter/AgaviExecutionFilter.class.php

    r2612 r2786  
    269269 
    270270    $isCacheable = false; 
    271     if($this->getParameter('enable_caching', true) && is_readable($cachingDotXml = AgaviConfig::get('core.module_dir') . '/' . $moduleName . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $actionName . '.xml')) { 
     271    $cachingDotXml = AgaviToolkit::expandVariables( 
     272      AgaviToolkit::expandDirectives( 
     273        AgaviConfig::get( 
     274          sprintf('modules.%s.agavi.cache.path', strtolower($moduleName)), 
     275          '%core.module_dir%/${moduleName}/cache/${actionName}.xml' 
     276        ) 
     277      ), 
     278      array( 
     279        'moduleName' => $moduleName, 
     280        'actionName' => $actionName, 
     281      ) 
     282    ); 
     283    if($this->getParameter('enable_caching', true) && is_readable($cachingDotXml)) { 
    272284      // $lm->log('Caching enabled, configuration file found, loading...'); 
    273285      // no _once please! 
     
    639651 
    640652      // get the current action validation configuration 
    641       $validationConfig = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/validate/' . $actionName . '.xml'; 
    642  
     653      $validationConfig = AgaviToolkit::expandVariables( 
     654        AgaviToolkit::expandDirectives( 
     655          AgaviConfig::get( 
     656            sprintf('modules.%s.agavi.validate.path', strtolower($moduleName)), 
     657            '%core.module_dir%/${moduleName}/validate/${actionName}.xml' 
     658          ) 
     659        ), 
     660        array( 
     661          'moduleName' => $moduleName, 
     662          'actionName' => $actionName, 
     663        ) 
     664      ); 
    643665      if(is_readable($validationConfig)) { 
    644666        // load validation configuration 
     
    699721    } elseif($viewName !== AgaviView::NONE) { 
    700722      // use a view related to this action 
    701       $viewName = $actionName . $viewName; 
     723      $viewName = AgaviToolkit::expandVariables( 
     724        AgaviToolkit::expandDirectives( 
     725          AgaviConfig::get( 
     726            sprintf('modules.%s.agavi.view.name', strtolower($moduleName)), 
     727            '${actionName}${viewName}' 
     728          ) 
     729        ), 
     730        array( 
     731          'actionName' => $actionName, 
     732          'viewName' => $viewName, 
     733        ) 
     734      ); 
    702735      $viewModule = $moduleName; 
    703736    } else { 
  • branches/1.0/src/view/AgaviFileTemplateLayer.class.php

    r2259 r2786  
    5656   
    5757  /** 
     58   * Initialize the layer. 
     59   * 
     60   * Will try and figure out an alternative default for "directory". 
     61   * 
     62   * @param      AgaviContext The current Context instance. 
     63   * @param      array        An array of initialization parameters. 
     64   * 
     65   * @author     David Zülke <david.zuelke@bitextender.com> 
     66   * @since      1.0.0 
     67   */ 
     68  public function initialize(AgaviContext $context, array $parameters = array()) 
     69  { 
     70    $this->setParameter( 
     71      'directory', 
     72      AgaviToolkit::expandDirectives( 
     73        AgaviConfig::get( 
     74          sprintf('modules.%s.agavi.template.directory', isset($parameters['module']) ? strtolower($parameters['module']) : ''), 
     75          '%core.module_dir%/${module}/templates' 
     76        ) 
     77      ) 
     78    ); 
     79     
     80    parent::initialize($context, $parameters); 
     81  } 
     82   
     83  /** 
    5884   * Get the full, resolved stream location name to the template resource. 
    5985   *