Search the Community
Showing results for tags 'registry'.
-
So I have a registry class that holds sub class instances. When the application loads a module, the registry class needs to make sub class functionality available to the module. There's an autoloader in place, I just need the class instances. A service manager should load the registry class with sub classes. Service manager RegistryClass has this prototype at the end of the process: // hash table of registry properties and classes // SiteNavigation example is one sub class RegistryClass Object( [data:RegistryClass:private] => [regList:RegistryClass:private] => Array ( [SiteNavigation] => SiteNavigation Object ( [siteConfig:protected] => [route:protected] => ) ) ) There are several MVC scripts in the module that require different things. However, when the script (ie module controller) picks up the Registry object, it's hash table (regList) is empty. // empty table, empty belly RegistryClass Object ( [data:RegistryClass:private] => [regList:RegistryClass:private] => Array ( ) ) I've tried using the built in PHP interface Serializable however, it's producing incomplete PHP objects when I call unserialize() method. Called from a module script - that looks like: $newObj = unserialize($serialized); // Registry appears fine, however, SiteNavigation is incomplete RegistryClass Object ( [data:RegistryClass:private] => [regList:RegistryClass:private] => Array ( [SiteNavigation] => __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => SiteNavigation [siteConfig:protected] => [route:protected] => ) ) ) Here is a snip from the service manager which 1. instantiates a singleton registry class 2. instantiates the sub classes. $regObj = RegistryClass::getInstance(); // Singleton class holds instances of sub classes in hash table /* * set() method simply assigns sub class names as key and object instance as value to regList */ if(class_exists($className)) { $regObj->set($className, new $className); } /* * now serialize and assign to session, RegistryClass implements Serializable */ $_SESSION['RegistryClass'] = $regObj->serialize($regObj); It seems like the sub classes (ie SiteNavigation) doesn't serialize. Error log output only C:13:"RegistryClass":2:{N;}). Any thoughts are appreciated.
- 5 replies
-
- serializable
- singleton
-
(and 2 more)
Tagged with: