Author: mtorres
Date: 2010-04-28 17:29:52 +0200 (Wed, 28 Apr 2010)
New Revision: 29301

Modified:
   
plugins/ncPropelChangeLogBehaviorPlugin/lib/adapter/ncChangeLogUpdateChange.class.php
Log:
Se agrego una se?\195?\177al global

Modified: 
plugins/ncPropelChangeLogBehaviorPlugin/lib/adapter/ncChangeLogUpdateChange.class.php
===================================================================
--- 
plugins/ncPropelChangeLogBehaviorPlugin/lib/adapter/ncChangeLogUpdateChange.class.php
       2010-04-28 15:28:22 UTC (rev 29300)
+++ 
plugins/ncPropelChangeLogBehaviorPlugin/lib/adapter/ncChangeLogUpdateChange.class.php
       2010-04-28 15:29:52 UTC (rev 29301)
@@ -8,6 +8,8 @@
     $adapter,
     $newValue;
 
+  
+
   public function __construct($fieldName, $oldValue, $newValue, $updateAdapter)
   {
     $this->fieldName  = $fieldName;
@@ -16,6 +18,56 @@
     $this->adapter    = $updateAdapter;
   }
 
+  /**
+   * Returns a propel column type or null if cannot fetch it. 
+   * Available column types are:
+
+      const CHAR = "CHAR";
+      const VARCHAR = "VARCHAR";
+      const LONGVARCHAR = "LONGVARCHAR";
+      const CLOB = "CLOB";
+      const NUMERIC = "NUMERIC";
+      const DECIMAL = "DECIMAL";
+      const TINYINT = "TINYINT";
+      const SMALLINT = "SMALLINT";
+      const INTEGER = "INTEGER";
+      const BIGINT = "BIGINT";
+      const REAL = "REAL";
+      const FLOAT = "FLOAT";
+      const DOUBLE = "DOUBLE";
+      const BINARY = "BINARY";
+      const VARBINARY = "VARBINARY";
+      const LONGVARBINARY = "LONGVARBINARY";
+      const BLOB = "BLOB";
+      const DATE = "DATE";
+      const TIME = "TIME";
+      const TIMESTAMP = "TIMESTAMP";
+
+      const BU_DATE = "BU_DATE";
+      const BU_TIMESTAMP = "BU_TIMESTAMP";
+
+      const BOOLEAN = "BOOLEAN";
+
+   *
+   */
+  public function getColumnType()
+  {
+    $peerClassName = $this->adapter->getEntry()->getObjectPeerClassName();
+
+    if (!is_null($peerClassName) && class_exists($peerClassName))
+    {
+      $tableMap = call_user_func(array($peerClassName , 'getTableMap'));
+      if (!is_null($tableMap) && ($tableMap !== false) && 
($tableMap->containsColumn($this->getFieldName())))
+      {
+        $column = $tableMap->getColumn($this->getFieldName());
+
+        return $column->getType();
+      }
+    }
+
+    return null;
+  }
+
   protected function getDispatcher()
   {
     if (sfContext::hasInstance())
@@ -28,10 +80,19 @@
     return new sfEvent(
       $this, 
       $this->adapter->getTableName().'.render_'.$this->getFieldName(),
-      array('fieldName' => $this->getFieldName())
+      array('fieldName' => $this->getFieldName(), 'tableName' => 
$this->adapter->getTableName(), 'fieldType' => $this->getColumnType())
     );
   }
 
+  protected function createGlobalEvent()
+  {
+    return new sfEvent(
+      $this, 
+      'ncChangeLog.render',
+      array('fieldName' => $this->getFieldName(), 'tableName' => 
$this->adapter->getTableName(), 'fieldType' => $this->getColumnType())
+    );
+  }
+
   public function getForeignValue($value, $method = '__toString')
   {
     if (ncChangeLogConfigHandler::getForeignValues() && $this->isForeignKey())
@@ -85,9 +146,13 @@
 
     if ($emitSignal)
     {
+      $globalEvent = $this->createGlobalEvent();
+      $this->getDispatcher()->filter($globalEvent, $value);
+      $res = $globalEvent->getReturnValue();
+
       $event = $this->createEvent();
-      $this->getDispatcher()->filter($event, $value);
-      $res   = $event->getReturnValue();
+      $this->getDispatcher()->filter($event, $res);
+      $res = $event->getReturnValue();
     }
 
     if (is_null($event) || (!$event->isProcessed() && !empty($value) && 
$this->isForeignKey()))

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