]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Managed_DataObject gets dynamic class detection for staticGet
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 12 Aug 2013 17:12:13 +0000 (19:12 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 12 Aug 2013 17:12:13 +0000 (19:12 +0200)
Compatibility: get_called_class is implemented in PHP >= 5.3.0

classes/Managed_DataObject.php

index 1d55537e20b800c3fe5ec70b130406a3397fcaa4..4886e79724c462789554a78a9ad077bcb6cfe161 100644 (file)
@@ -30,6 +30,21 @@ abstract class Managed_DataObject extends Memcached_DataObject
      */
     public static abstract function schemaDef();
 
+    /**
+     * Get an instance by key
+     *
+     * @param string $k Key to use to lookup (usually 'id' for this class)
+     * @param mixed  $v Value to lookup
+     *
+     * @return get_called_class() object if found, or null for no hits
+     *
+     */
+    static function staticGet($k,$v=NULL)
+    {
+        return parent::staticGet(get_called_class(),$k,$v);
+    }
+
+
     /**
      * get/set an associative array of table columns
      *
@@ -202,4 +217,4 @@ abstract class Managed_DataObject extends Memcached_DataObject
         }
         return $ckeys;
     }
-}
\ No newline at end of file
+}