Author: Jonathan.Wage
Date: 2010-01-27 23:55:48 +0100 (Wed, 27 Jan 2010)
New Revision: 27258

Modified:
   plugins/sfSympalPlugin/trunk/lib/behaviors/sfSympalRecordTemplate.class.php
Log:
[1.4][sfSympalPlugin][1.0] Ugly and hopefully temporary hack to work around 
migrations issue until better solution is found


Modified: 
plugins/sfSympalPlugin/trunk/lib/behaviors/sfSympalRecordTemplate.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/behaviors/sfSympalRecordTemplate.class.php 
2010-01-27 22:07:38 UTC (rev 27257)
+++ plugins/sfSympalPlugin/trunk/lib/behaviors/sfSympalRecordTemplate.class.php 
2010-01-27 22:55:48 UTC (rev 27258)
@@ -2,7 +2,9 @@
 
 class sfSympalRecordTemplate extends Doctrine_Template
 {
-  protected $_eventName;
+  protected
+    $_eventName,
+    $_modelName;
 
   public function setInvoker(Doctrine_Record_Abstract $invoker)
   {
@@ -73,7 +75,7 @@
   public function isI18ned()
   {
     $i18nedModels = sfSympalConfig::get('internationalized_models', null, 
array());
-    return sfSympalConfig::get('i18n') && 
isset($i18nedModels[$this->_table->getOption('name')]);
+    return sfSympalConfig::get('i18n') && 
isset($i18nedModels[$this->getModelName()]);
   }
 
   public function getI18nedFields()
@@ -81,7 +83,7 @@
     if ($this->isI18ned())
     {
       $i18nedModels = sfSympalConfig::get('internationalized_models', null, 
array());
-      return $i18nedModels[$this->_table->getOption('name')];
+      return $i18nedModels[$this->getModelName()];
     } else {
       return array();
     }
@@ -90,7 +92,7 @@
   public function isSluggable()
   {
     $sluggableModels = sfSympalConfig::get('sluggable_models', null, array());
-    return array_key_exists($this->_table->getOption('name'), 
$sluggableModels);
+    return array_key_exists($this->getModelName(), $sluggableModels);
   }
 
   public function getSluggableOptions()
@@ -98,7 +100,7 @@
     if ($this->isSluggable())
     {
       $sluggableModels = sfSympalConfig::get('sluggable_models', null, 
array());
-      return $sluggableModels[$this->_table->getOption('name')] ? 
$sluggableModels[$this->_table->getOption('name')]:array();
+      return $sluggableModels[$this->getModelName()] ? 
$sluggableModels[$this->getModelName()]:array();
     } else {
       return array();
     }
@@ -106,6 +108,21 @@
 
   public function isContent()
   {
-    return $this->_table->getOption('name') == 'sfSympalContent' ? true:false;
+    return $this->getModelName() == 'sfSympalContent' ? true:false;
   }
+
+  /**
+   * Hack for working around the ToPrfx and FromPrfx prefix used by migrations
+   *
+   * @return string $modelName
+   */
+  public function getModelName()
+  {
+    if (!$this->_modelName)
+    {
+      $this->_modelName = str_replace('ToPrfx', '', 
$this->_table->getOption('name'));
+      $this->_modelName = str_replace('FromPrfx' ,'', $this->_modelName);
+    }
+    return $this->_modelName;
+  }
 }
\ 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