function initialize() { $this->get_registry()->apply_adapters($this); $this->adapted = TRUE; register_shutdown_function(array(&$this, 'update_cache')); $this->_method_map_cache = (array) C_Pope_Cache::get(array($this->context, $this->_mixin_priorities, $this->_disabled_map), $this->_method_map_cache); }
/** * There really isn't any concept of 'parent' method. An ExtensibleObject * instance contains an ordered array of extension classes, which provides * the method implementations for the instance to use. Suppose that an * ExtensibleObject has two extension, and both have the same methods.The * last extension appears to 'override' the first extension. So, instead of calling * a 'parent' method, we're actually just calling an extension that was added sooner than * the one that is providing the current method implementation. */ function call_parent($method) { $retval = NULL; // To simulate a 'parent' call, we remove the current mixin providing the // implementation. $klass = $this->object->get_mixin_providing($method); // Perform the routine described above... $this->object->disable_mixin_for($method, $klass); // Get the method map cache $orig_method_map = $this->object->_method_map_cache; $this->object->_method_map_cache = (array) C_Pope_Cache::get(array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map), $this->object->_method_map_cache); // Call anchor $args = func_get_args(); // Remove $method parameter array_shift($args); // Execute the method $retval = $this->object->call_method($method, $args); // Cache the method map for this configuration of mixins C_Pope_Cache::set(array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map), $this->object->_method_map_cache); // Re-enable mixins; // $this->object->add_mixin($klass); $this->object->enable_mixin_for($method, $klass); // Restore the original method map $this->object->_method_map_cache = $orig_method_map; return $retval; }
/** * Autoloads any classes, interfaces, or adapters needed by this module */ function _module_autoload($name) { // Pope classes are always prefixed if (strpos($name, 'C_') !== 0 && strpos($name, 'A_') !== 0 && strpos($name, 'Mixin_') !== 0) { return; } if ($this->_module_type_cache == null || count($this->_modules) > $this->_module_type_cache_count) { $this->_module_type_cache_count = count($this->_modules); $modules = $this->_modules; $keys = array(); foreach ($modules as $mod => $properties) { $keys[$mod] = $properties->module_version; } if (!($this->_module_type_cache = C_Pope_Cache::get($keys, array()))) { foreach ($modules as $module_id => $module) { $dir = $this->get_module_dir($module_id); $type_list = $module->get_type_list(); foreach ($type_list as $type => $filename) { $this->_module_type_cache[strtolower($type)] = $dir . DIRECTORY_SEPARATOR . $filename; } } C_Pope_Cache::set($keys, $this->_module_type_cache); } elseif (is_object($this->_module_type_cache)) { $this->_module_type_cache = get_object_vars($this->_module_type_cache); } } $name = strtolower($name); if (isset($this->_module_type_cache[$name])) { $module_filename = $this->_module_type_cache[$name]; if (file_exists($module_filename)) { require_once $module_filename; } } }