Author: Jonathan.Wage
Date: 2010-03-25 03:35:07 +0100 (Thu, 25 Mar 2010)
New Revision: 28775

Added:
   plugins/sfSympalPlugin/trunk/test/unit/sfSympalContentListPlugin/
   plugins/sfSympalPlugin/trunk/test/unit/sfSympalContentListPlugin/model/
   
plugins/sfSympalPlugin/trunk/test/unit/sfSympalContentListPlugin/model/doctrine/
   
plugins/sfSympalPlugin/trunk/test/unit/sfSympalContentListPlugin/model/doctrine/PluginsfSympalContentListTest.php
Modified:
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/model/doctrine/PluginsfSympalContentList.class.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenu.class.php
   plugins/sfSympalPlugin/trunk/lib/route/sfSympalContentRouteObject.class.php
   plugins/sfSympalPlugin/trunk/test/unit/DataGridTest.php
Log:
[sfSympalPlugin] Synchronizing git repository to Symfony Plugins SVN

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/model/doctrine/PluginsfSympalContentList.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/model/doctrine/PluginsfSympalContentList.class.php
   2010-03-25 00:55:12 UTC (rev 28774)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/model/doctrine/PluginsfSympalContentList.class.php
   2010-03-25 02:35:07 UTC (rev 28775)
@@ -15,14 +15,20 @@
       if ($q instanceof sfSympalDataGrid)
       {
         $dataGrid = $q;
-      } else if ($q instanceof sfDoctrinePager || $q instanceof 
Doctrine_Query_Abstract) {
+      }
+      else if ($q instanceof sfDoctrinePager || $q instanceof 
Doctrine_Query_Abstract)
+      {
         $dataGrid = sfSympalDataGrid::create($q);
-      } else {
+      }
+      else
+      {
         throw new sfException(sprintf('ContentList table_method must return an 
instance of sfSympalDataGrid, sfDoctrinePager or Doctrine_Query_Abstract. An 
instance of "%s" was returned.', get_class($q)));
       }
-    } else {
+    }
+    else
+    {
       $pager = new sfDoctrinePager('sfSympalContent');
-      $pager->setQuery($this->_buildQuery($request));
+      $pager->setQuery($this->_buildQuery());
 
       $dataGrid = sfSympalDataGrid::create($pager)
         ->addColumn('c.title', 'renderer=sympal_data_grid/default_title')
@@ -42,14 +48,18 @@
     return $dataGrid;
   }
 
-  private function _buildQuery(sfWebRequest $request)
+  private function _buildQuery()
   {
     $table = Doctrine_Core::getTable('sfSympalContent');
 
-    if ($this->dql_query) {
+    if ($this->dql_query)
+    {
       $q = $table->createQuery()->query($this->dql_query);
-    } else {
+    }
+    else
+    {
       $q = $table->getFullTypeQuery($this->ContentType->name);
+      $q = $table->addPublishedQuery('c', $q);
     }
 
     return $q;

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenu.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenu.class.php
 2010-03-25 00:55:12 UTC (rev 28774)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenu.class.php
 2010-03-25 02:35:07 UTC (rev 28775)
@@ -123,9 +123,32 @@
     return $this->_route;
   }
 
+  /**
+   * Generates the url to this menu item based on the route
+   * 
+   * In case the route is totally invalid, this catches the exception
+   * and sends to the raw string
+   * 
+   * @TODO Find a more explicit way to log if the route is invalid
+   * 
+   * @param array $options Options to pass to the url_for method
+   */
   public function getUrl(array $options = array())
   {
-    return url_for($this->getRoute(), $options);
+    try
+    {
+      return url_for($this->getRoute(), $options);
+    }
+    catch (sfConfigurationException $e)
+    {
+      sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(
+        new sfEvent($this, 'application.log', array(
+          sprintf('Cannot generate a menu url for "%s"', $this->getRoute())
+        ))
+      );
+      
+      return $this->getRoute();
+    }
   }
 
   public function setRoute($route)

Modified: 
plugins/sfSympalPlugin/trunk/lib/route/sfSympalContentRouteObject.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/route/sfSympalContentRouteObject.class.php 
2010-03-25 00:55:12 UTC (rev 28774)
+++ plugins/sfSympalPlugin/trunk/lib/route/sfSympalContentRouteObject.class.php 
2010-03-25 02:35:07 UTC (rev 28775)
@@ -149,6 +149,11 @@
     $isI18nEnabled = sfSympalConfig::isI18nEnabled();
 
     $languageCodes = $isI18nEnabled ? sfSympalConfig::getLanguageCodes() : 
array($this->getCurrentCulture());
+    if (!is_array($languageCodes))
+    {
+      throw new sfException(sprintf('Language codes is not an array: "%s" 
given', $languageCodes));
+    }
+    
     $values = array();
     foreach ($languageCodes as $code)
     {

Modified: plugins/sfSympalPlugin/trunk/test/unit/DataGridTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/test/unit/DataGridTest.php     2010-03-25 
00:55:12 UTC (rev 28774)
+++ plugins/sfSympalPlugin/trunk/test/unit/DataGridTest.php     2010-03-25 
02:35:07 UTC (rev 28775)
@@ -1,5 +1,15 @@
 <?php
 
+/**
+ * Unit test for the sfSympalDataGrid class
+ * 
+ * @package     sfSympalDataGridPlugin
+ * @subpackage  test
+ * @author      Jonathan H. Wage <[email protected]>
+ * @since       2010-03-24
+ * @version     svn:$Id$ $Author$
+ */
+
 $app = 'sympal';
 require_once(dirname(__FILE__).'/../bootstrap/unit.php');
 

Added: 
plugins/sfSympalPlugin/trunk/test/unit/sfSympalContentListPlugin/model/doctrine/PluginsfSympalContentListTest.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/test/unit/sfSympalContentListPlugin/model/doctrine/PluginsfSympalContentListTest.php
                           (rev 0)
+++ 
plugins/sfSympalPlugin/trunk/test/unit/sfSympalContentListPlugin/model/doctrine/PluginsfSympalContentListTest.php
   2010-03-25 02:35:07 UTC (rev 28775)
@@ -0,0 +1,22 @@
+<?php
+
+$app = 'sympal';
+require_once(dirname(__FILE__).'/../../../../bootstrap/unit.php');
+
+$t = new lime_test(2);
+
+$page = sfSympalContent::createNew('sfSympalPage');
+$page->date_published = date('Y-m-d h:i:s', time() + 86400); // tomorrow
+$page->save();
+
+$pageContentType = 
Doctrine_Core::getTable('sfSympalContentType')->findOneByName('sfSympalPage');
+
+$contentList = sfSympalContent::createNew('sfSympalContentList');
+$contentList->ContentType = $pageContentType;
+$contentList->save();
+
+/**
+ * This will test PluginsfSympalContentList, but buildDataGrid() currently
+ * has an sfWebRequest dependency on it, which needs to be removed.
+ * See ticket #23
+ */
\ No newline at end of file

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