Author: ornicar2
Date: 2010-02-10 19:30:14 +0100 (Wed, 10 Feb 2010)
New Revision: 27835

Added:
   plugins/dmTagPlugin/config/dmTagPluginConfiguration.class.php
Modified:
   plugins/dmTagPlugin/
   plugins/dmTagPlugin/lib/doctrine/extension/DmTaggable/Template/DmTaggable.php
Log:
[Diem][dmTagPlugin]
- fixed bug when using DmTag before taggable models are loaded
- added svn:ignore


Property changes on: plugins/dmTagPlugin
___________________________________________________________________
Added: svn:ignore
   + .settings
.project
.buildpath
nbproject
project.*


Added: plugins/dmTagPlugin/config/dmTagPluginConfiguration.class.php
===================================================================
--- plugins/dmTagPlugin/config/dmTagPluginConfiguration.class.php               
                (rev 0)
+++ plugins/dmTagPlugin/config/dmTagPluginConfiguration.class.php       
2010-02-10 18:30:14 UTC (rev 27835)
@@ -0,0 +1,44 @@
+<?php
+
+class dmTagPluginConfiguration extends sfPluginConfiguration
+{
+  public function configure()
+  {
+    $this->dispatcher->connect('dm.context.loaded', 
array($this,'listenToDmContextLoaded'));
+  }
+
+  public function listenToDmContextLoaded(sfEvent $e)
+  {
+    $cache = $e->getSubject()->get('cache_manager')->getCache('dm_tag');
+
+    foreach($this->getTaggableModels($cache) as $model)
+    {
+      dmDb::table($model);
+    }
+  }
+
+  /**
+   * @param sfCache $cache
+   * @return array models that act as DmTaggable
+   */
+  public function getTaggableModels(sfCache $cache)
+  {
+    if($cache->has('taggable_models'))
+    {
+      return $cache->get('taggable_models');
+    }
+
+    $models = array();
+    foreach(dmProject::getAllModels() as $model)
+    {
+      if(dmDb::table($model)->hasTemplate('DmTaggable'))
+      {
+        $models[] = $model;
+      }
+    }
+
+    $cache->set('taggable_models', $models);
+
+    return $models;
+  }
+}
\ No newline at end of file

Modified: 
plugins/dmTagPlugin/lib/doctrine/extension/DmTaggable/Template/DmTaggable.php
===================================================================
--- 
plugins/dmTagPlugin/lib/doctrine/extension/DmTaggable/Template/DmTaggable.php   
    2010-02-10 18:00:40 UTC (rev 27834)
+++ 
plugins/dmTagPlugin/lib/doctrine/extension/DmTaggable/Template/DmTaggable.php   
    2010-02-10 18:30:14 UTC (rev 27835)
@@ -113,7 +113,7 @@
   public function getCurrentTagIds()
   {
     $tagIds = array();
-    foreach ($this->getTags() as $tag)
+    foreach ($this->getInvoker()->get('Tags') as $tag)
     {
       $tagIds[] = $tag->get('id');
     }

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