We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit d115cddf authored by mattl's avatar mattl

Managed_DataObject gets dynamic class detection for staticGet

Compatibility: get_called_class is implemented in PHP >= 5.3.0
parent 3394efca
...@@ -30,6 +30,21 @@ abstract class Managed_DataObject extends Memcached_DataObject ...@@ -30,6 +30,21 @@ abstract class Managed_DataObject extends Memcached_DataObject
*/ */
public static abstract function schemaDef(); 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 * get/set an associative array of table columns
* *
...@@ -202,4 +217,4 @@ abstract class Managed_DataObject extends Memcached_DataObject ...@@ -202,4 +217,4 @@ abstract class Managed_DataObject extends Memcached_DataObject
} }
return $ckeys; return $ckeys;
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment