alecwhardy
alecwhardy

Reputation: 2718

Store an object in Zend Registry

How do you store an object in a Zend_Registry instance so that each property of the object is loaded as the index and each value of the object's property is stored as the registry's value?

Upvotes: 1

Views: 416

Answers (1)

alecwhardy
alecwhardy

Reputation: 2718

Answered my own question. Create a class extending Zend_Registry and add the following method:

public static function loadObject($object){
    $data = get_object_vars($object);
    foreach($data as $key => $value){
        self::set($key, $value);
    }
}

Upvotes: 1

Related Questions