Author: Jonathan.Wage
Date: 2010-01-31 17:05:45 +0100 (Sun, 31 Jan 2010)
New Revision: 27353
Modified:
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentType.class.php
Log:
[1.4][sfSympalPlugin][1.0] Fixing issue with infinite loop
Modified:
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php
2010-01-31 16:00:04 UTC (rev 27352)
+++
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php
2010-01-31 16:05:45 UTC (rev 27353)
@@ -459,16 +459,25 @@
}
}
+ public function hasCustomPath()
+ {
+ return $this->custom_path ? true : false;
+ }
+
public function getRoutePath()
{
- if ($path = $this['custom_path'])
+ // If content has a custom path then lets use it
+ if ($this->hasCustomPath())
{
+ $path = $this->custom_path;
if ($path != '/')
{
$path .= '.:sf_format';
}
return $path;
}
+ // If content has a custom module or action then we need a route for it
+ // so generate a path for this content to use in the route
else if ($this->get('module', false) || $this->get('action', false))
{
$values = $this->_buildRouteValues();
@@ -476,26 +485,33 @@
$values['sf_format'] = ':sf_format';
return $this->getRouteObject()->generate($values);
}
- else if ($path = $this['Type']['route_path'])
+ // Otherwise fallback and get route path from the content type
+ else if ($path = $this->getType()->getRoutePath())
{
return $path;
}
+ // Default if nothing else can be found
else if ($this['slug'])
{
return '/content/:slug';
}
}
- public function getRouteObject($path = null)
+ public function getRouteObject()
{
if (!$this->_routeObject)
{
- if (is_null($path))
+ // Generate a route object for this content only if it has a custom path
+ if ($this->hasCustomPath())
{
- $path = $this->getRoutePath();
+ $this->_routeObject = new sfRoute($this->getRoutePath(), array(
+ 'sf_format' => 'html',
+ 'sf_culture' => sfConfig::get('default_culture')
+ ));
+ // Otherwise get it from the content type
+ } else {
+ $this->_routeObject = $this->getType()->getRouteObject();
}
-
- $this->_routeObject = new sfRoute($path, array('sf_format' => 'html',
'sf_culture' => sfConfig::get('default_culture')));
}
return $this->_routeObject;
}
Modified:
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentType.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentType.class.php
2010-01-31 16:00:04 UTC (rev 27352)
+++
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentType.class.php
2010-01-31 16:05:45 UTC (rev 27353)
@@ -5,6 +5,8 @@
*/
abstract class PluginsfSympalContentType extends BasesfSympalContentType
{
+ protected $_routeObject;
+
public function __toString()
{
return (string) $this->getLabel();
@@ -45,6 +47,18 @@
return $path;
}
+ public function getRouteObject()
+ {
+ if (!$this->_routeObject)
+ {
+ $this->_routeObject = new sfRoute($this->getRoutePath(), array(
+ 'sf_format' => 'html',
+ 'sf_culture' => sfConfig::get('default_culture')
+ ));
+ }
+ return $this->_routeObject;
+ }
+
public function getCustomModuleName()
{
if ($moduleName = $this->_get('module'))
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" 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/symfony-svn?hl=en.