Author: jablko
Date: Tue Oct 26 09:42:08 2010
New Revision: 8505

Log:
Respect ->slug property

Modified:
   trunk/lib/model/QubitObject.php

Modified: trunk/lib/model/QubitObject.php
==============================================================================
--- trunk/lib/model/QubitObject.php     Tue Oct 26 09:28:25 2010        (r8504)
+++ trunk/lib/model/QubitObject.php     Tue Oct 26 09:42:08 2010        (r8505)
@@ -21,6 +21,35 @@
 
 class QubitObject extends BaseObject implements Zend_Acl_Resource_Interface
 {
+  public function __isset($name)
+  {
+    $args = func_get_args();
+
+    switch ($name)
+    {
+      case 'slug':
+
+        if (!isset($this->values['slug']))
+        {
+          $connection = Propel::getConnection(QubitObject::DATABASE_NAME);
+
+          $statement = $connection->prepare('
+            SELECT '.QubitSlug::SLUG.'
+            FROM '.QubitSlug::TABLE_NAME.'
+            WHERE ? = '.QubitSlug::OBJECT_ID);
+          $statement->execute(array($this->id));
+          $row = $statement->fetch();
+          $this->values['slug'] = $row[0];
+        }
+
+        return isset($this->values['slug']);
+
+      default:
+
+        return call_user_func_array(array($this, 'BaseObject::__isset'), 
$args);
+    }
+  }
+
   public function __get($name)
   {
     $args = func_get_args();
@@ -163,6 +192,18 @@
     return $this;
   }
 
+  protected function insert($connection = null)
+  {
+    parent::insert($connection);
+
+    if (isset($this->slug))
+    {
+      QubitSlug::staticInsert($this->id, $this->slug, $connection);
+    }
+
+    return $this;
+  }
+
   public function delete($connection = null)
   {
     if (!isset($connection))

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" 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/qubit-commits?hl=en.

Reply via email to