Ticket #668 (closed enhancement: fixed)

Opened 11 months ago

Last modified 2 months ago

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

Reported by: david Owned by: david
Priority: low Milestone: 1.0
Component: _OTHER_ Version:
Severity: normal Keywords:
Cc: Patch attached: no

Description (last modified by david) (diff)

so instead of

$file = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/actions/' . $actionName . 'Action.class.php';

in AgaviController::createActionInstance() we expand directives and variables on a string read from, say, "modules.modulename.agavi.action.path", that defaults to something like

%core.module_dir%/${moduleName}/actions/{$actionName}Action.class.php

So you could get rid of the separate folders for view, tpl etc per action by having something like

%core.module_dir%/${moduleName}/{$actionName}/Action.class.php

for the action,

%core.module_dir%/${moduleName}/{$actionName}/validate.xml

for the validation xml and so on.

All of this should be per-module, as otherwise, modules are not really interchangeable.

Difficult: the Views. They have a scheme like Default_Sub_MarineSuccessView, which won't work unless Marine and Success (in this example) are separate. That means we also need customization of the way a View shortname (Success) and an Action name are concatenated.

Also, template paths are defined through layouts, and handled in AgaviTemplateLayer classes, where we can only really adjust directory, not all targets, since those are defined globally.

Attachments

Change History

Changed 3 months ago by david

  • milestone changed from 1.1 to 1.3

Changed 3 months ago by david

this has implications for the build system, too, mind you

Changed 3 months ago by david

  • status changed from new to assigned
  • milestone changed from 1.3 to 1.0

Changed 3 months ago by david

  • description modified (diff)
  • summary changed from Make filesystem path rules configuration directive based to Allow customization of Action/View/Template/Caching/Validation file lookup paths and View shortname resolution

Changed 3 months ago by david

  • summary changed from Allow customization of Action/View/Template/Caching/Validation file lookup paths and View shortname resolution to Allow customization of the way Actions, Views etc. are laid out in the filesystem

Changed 3 months ago by david

And then, in a new-style module.xml (#834):

<setting name="agavi.action.path">%core.module_dir%/${moduleName}/${actionName}/Action.class.php</setting>
<setting name="agavi.cache.path">%core.module_dir%/${moduleName}/${actionName}/cache.xml</setting>
<setting name="agavi.template.directory">%core.module_dir%/${module}</setting>
<setting name="agavi.validate.path">%core.module_dir%/${moduleName}/${actionName}/validate.xml</setting>
<setting name="agavi.view.path">%core.module_dir%/${moduleName}/${viewName}View.class.php</setting>
<setting name="agavi.view.name">${actionName}/${viewName}</setting>

Of course, you can also put this into its own <settings> block and XInclude from elsewhere...

Changed 3 months ago by david

  • status changed from assigned to closed
  • resolution set to fixed

(In [2786]) Allow customization of the way Actions, Views etc. are laid out in the filesystem, closes #668

Changed 3 months ago by david

I should mention that the following structure is much nicer:

<setting name="agavi.action.path">%core.module_dir%/${moduleName}/impl/${actionName}/Action.class.php</setting>
<setting name="agavi.cache.path">%core.module_dir%/${moduleName}/impl/${actionName}/cache.xml</setting>
<setting name="agavi.template.directory">%core.module_dir%/${module}/impl/</setting>
<setting name="agavi.validate.path">%core.module_dir%/${moduleName}/impl/${actionName}/validate.xml</setting>
<setting name="agavi.view.path">%core.module_dir%/${moduleName}/impl/${viewName}View.class.php</setting>
<setting name="agavi.view.name">${actionName}/${viewName}</setting>

as you then have this structure:

app
  modules
    Default
      config
      impl
      lib
      models

with all actions, views, templates and cache/validation configs inside impl/

note that the example (has to) customize the view name, so you now have a slash (subdir) in the view filename (and an underscore in the class name) between action name and view shortname (Success, Input etc)... example: Default_Sub_Marine_SuccessView instead of Default_Sub_MarineSuccessView

also, using the template lookup pattern where there is a directory per locale does not make much sense with this layout

Changed 2 months ago by david

Also mind you you need to set up config handlers in your application's or module's config_handlers.xml:

<handler pattern="%core.module_dir%/*/impl/*/validate.xml" class="AgaviValidatorConfigHandler">
  <validation>%core.agavi_dir%/config/xsd/validators.xsd</validation>
</handler>
<handler pattern="%core.module_dir%/*/impl/*/cache.xml" class="AgaviCachingConfigHandler">
  <validation>%core.agavi_dir%/config/xsd/caching.xsd</validation>
</handler>

Add/Change #668 (Allow customization of the way Actions, Views etc. are laid out in the filesystem)

Author



Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.