Author: sevein
Date: Tue Jul 26 14:04:03 2011
New Revision: 9385
Log:
Make QubitRoute capable to figure out module name if given value is '?', see
relation/actions/indexAction.class.php example
Modified:
trunk/apps/qubit/modules/relation/actions/indexAction.class.php
trunk/lib/QubitRoute.class.php
Modified: trunk/apps/qubit/modules/relation/actions/indexAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/relation/actions/indexAction.class.php Tue Jul
26 14:02:09 2011 (r9384)
+++ trunk/apps/qubit/modules/relation/actions/indexAction.class.php Tue Jul
26 14:04:03 2011 (r9385)
@@ -40,12 +40,12 @@
if (isset($this->resource->object))
{
- $value['object'] = $this->context->routing->generate(null,
array($this->resource->object));
+ $value['object'] = $this->context->routing->generate(null,
array($this->resource->object, 'module' => '?'));
}
if (isset($this->resource->subject))
{
- $value['subject'] = $this->context->routing->generate(null,
array($this->resource->subject));
+ $value['subject'] = $this->context->routing->generate(null,
array($this->resource->subject, 'module' => '?'));
}
if (isset($this->resource->type))
Modified: trunk/lib/QubitRoute.class.php
==============================================================================
--- trunk/lib/QubitRoute.class.php Tue Jul 26 14:02:09 2011 (r9384)
+++ trunk/lib/QubitRoute.class.php Tue Jul 26 14:04:03 2011 (r9385)
@@ -59,6 +59,31 @@
*/
public function generate($params, $context = array(), $absolute = false)
{
+ // Set module parameter if user asked it (module is '?')
+ if (!is_object($params) && '?' === @$params['module'])
+ {
+ $params['module'] = self::getModuleName($params[0]['className']);
+ }
+
return parent::generate($this->filterParams($params), $context, $absolute);
}
+
+ /**
+ * Try to figure out the module name of a Qubit object
+ */
+ public function getModuleName($className)
+ {
+ $module = str_replace('qubit', '', strtolower($className));
+
+ switch ($module)
+ {
+ case 'informationobject':
+ case 'actor':
+ case 'repository':
+
+ return
sfContext::getInstance()->routing->getDefaultParameter($module.'_template');
+ }
+
+ return $module;
+ }
}
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.