Author: Jonathan.Wage
Date: 2010-01-17 21:32:05 +0100 (Sun, 17 Jan 2010)
New Revision: 26780

Modified:
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenu.class.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSite.class.php
Log:
[1.4][sfSympalPlugin][1.0] Fixing issues with menu cache


Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenu.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenu.class.php
 2010-01-17 19:58:26 UTC (rev 26779)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenu.class.php
 2010-01-17 20:32:05 UTC (rev 26780)
@@ -457,6 +457,7 @@
 
   public function isCurrentAncestor()
   {
+    $ret = false;
     if ($currentObject = $this->_currentObject)
     {
       while ($currentObject->getLevel() != 0)

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSite.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSite.class.php
     2010-01-17 19:58:26 UTC (rev 26779)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSite.class.php
     2010-01-17 20:32:05 UTC (rev 26780)
@@ -21,6 +21,11 @@
     return false;
   }
 
+  public function getMenuItem()
+  {
+    return $this->_menuItem;
+  }
+
   public function getPathAsString()
   {
     $path = array();
@@ -73,24 +78,40 @@
     return 
sfSympalMenuBreadcrumbs::generate($this->getBreadcrumbsArray($subItem));
   }
 
-  public function setMenuItem(sfSympalMenuItem $menuItem)
+  protected function _prepareMenuItem($menuItem)
   {
-    $this->_route = $menuItem->getItemRoute();
-    $this->_menuItem = $menuItem->toArray(false);
-    unset($this->_menuItem['__children']);
+    if ($menuItem instanceof sfSympalMenuItem)
+    {
+      $array = $menuItem->toArray(false);
+      $array['item_route'] = $menuItem->getItemRoute();
+      $array['requires_auth'] = $menuItem->getRequiresAuth();
+      $array['requires_no_auth'] = $menuItem->getRequiresNoAuth();
+      $array['all_permissions'] = $menuItem->getAllPermissions();
+      $array['level'] = $menuItem->getLevel();
+      unset($array['__children']);
+      return $array;
+    }
+    return $menuItem;
+  }
 
-    $this->requiresAuth($menuItem->requires_auth);
-    $this->requiresNoAuth($menuItem->requires_no_auth);
-    $this->setCredentials($menuItem->getAllPermissions());
+  public function setMenuItem($menuItem)
+  {
+    $this->_menuItem = $this->_prepareMenuItem($menuItem);
+    $this->setRoute($this->_menuItem['item_route']);
+    $this->requiresAuth($this->_menuItem['requires_auth']);
+    $this->requiresNoAuth($this->_menuItem['requires_no_auth']);
+    $this->setCredentials($this->_menuItem['all_permissions']);
 
     $currentMenuItem = sfSympalContext::getInstance()->getCurrentMenuItem();
 
     if ($currentMenuItem && $currentMenuItem->exists())
     {
-      $this->isCurrent($menuItem->id == $currentMenuItem->id);
+      $this->isCurrent($this->_menuItem['id'] == $currentMenuItem['id']);
+    } else {
+      $this->isCurrent(false);
     }
 
-    $this->setLevel($menuItem->level);
+    $this->setLevel($this->_menuItem['level']);
   }
 
   public function getTopLevelParent()
@@ -107,11 +128,11 @@
     return $this;
   }
 
-  public function getMenuItemSubMenu(sfSympalMenuItem $menuItem)
+  public function getMenuItemSubMenu($menuItem)
   {
     foreach ($this->_children as $child)
     {
-      if ($child->getMenuItem()->id == $menuItem->id && $child->getChildren())
+      if ($child->_menuItem['id'] == $menuItem['id'] && $child->getChildren())
       {
         $result = $child;
       } else if ($n = $child->getMenuItemSubMenu($menuItem)) {

-- 
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.


Reply via email to