Class midcom_helper__componentloader

Description

This class is a Factory that is responsible for loading and establishing the interface to a MidCOM Component.

Working with components

Normally, two things are important when you deal with other components:

First, if you want to list other components, or for example check whether they are available, you should use the component manifest listing, known as $manifests. It gives you all meta-information about the components.

This should actually suffice for most normal operations.

If you develop framework tools (like administration interfaces, you will also need access to the component interface class, which can be obtained by get_component_class(). This class is derived from the component interface baseclass and should give you everything you need to work with the component and its information itself.

Other then that, you should not have to deal with the components, perhaps with the only exception of is_loaded() and load() to ensure other components are loaded in case you need them and they are not a pure-code library.

Loading components

When the component loader receives a request it roughly works in three stages:

  1. Verify that the given component is valid in terms of the MidCOM Specification. This will check the existence of all required SnippetDirs.
  2. Load all Snippets related with the MidCOM Interface Concept Classes and instantiate the MidCOM and Component concept classes, initialize the Component. Check whether all required concept classes exist.
  3. Return the various interface concepts upon each request from the framework.
Stage 1 will do all basic sanity checking possible before loading any snippets. It will check for the existence of all defined sub-SnippetDirs that are required for the system to work. If anything is missing, step 1 fails and the componentloader refuses to load the component.

Stage 2 will then load the interfaces.php file from the midcom directory. The existence of all required Interface classes is then checked. If this check is successful, the concrete classes of the various interface concepts are instantiated and stored internally. The component is initialized by the call to MIDCOM::initialize() which should load everything necessary.

Stage 3 is the final stage where the loader stays in memory in order to return references (!) to the loaded component's Interface Classes upon request.

In case you need an instance of the component loader to verify or transform component paths, use the function midcom_application::get_component_loader, which returns a reference to the loader.

Located in /midcom.core/midcom/helper/_componentloader.php (line 75)


	
			
Variable Summary
array $manifests
Method Summary
midcom_helper__componentloader __construct ()
Array get_all_manifest_customdata (string $component, [boolean $showempty = false])
array get_component_dependencies (string $component)
void get_component_icon ( $component, [ $provide_fallback = true])
mixed get_component_property (string $component, int $key)
mixed &get_midcom_class (string $path)
void is_core_component (string $component)
boolean is_loaded (string $path)
void load (string $path)
void load_all ()
boolean load_graceful (string $path)
void load_manifest (object $manifest)
string path_to_prefix (string $path)
string path_to_snippetpath (string $path)
string snippetpath_to_prefix (string $snippetpath)
void trigger_watches (int $operation, mixed $object)
boolean validate_path (string $snippetpath)
boolean validate_url (string $path)
void _generate_class_manifest_cache (string $cache_identifier)
Variables
array $manifests = array() (line 183)

This lists all available components in the systems in the form of their manifests, indexed by the component name. Whenever possible you should refer to this listing to gain information about the components available.

This information is loaded during startup.

Methods
Constructor __construct (line 223)

The constructor will initialize the class. Nothing special is done here. The real initialization is done in initialize() so that we already have a reference to ourselves.

midcom_helper__componentloader __construct ()
get_all_manifest_customdata (line 939)

This small helper builds a complete set of custom data associated with a given component identifier. In case a given component does not have the key set and the boolean parameter is set to true, an empty array is added implicitly.

  • return: All found component data indexed by known components.
Array get_all_manifest_customdata (string $component, [boolean $showempty = false])
  • string $component: The custom data component index to look for.
  • boolean $showempty: Set this flag to true to get an (empty) entry for all components which don't have customdata applicable to the component index given. This is disabled by default.
get_component_dependencies (line 962)

Get list of component and its dependencies depend on

  • return: List of dependencies
  • access: public
array get_component_dependencies (string $component)
  • string $component: Name of a component
get_component_icon (line 1071)
  • access: public
void get_component_icon ( $component, [ $provide_fallback = true])
  • $component
  • $provide_fallback
get_component_property (line 503)

Returns a property value for the component identified by the

MidCOM Path $path and the property key $key. It will return NULL if the property key is unknown. Remember to make a type sensitive comparison here. If the component is not loaded, the framework tries to load it, see _componentloader::load for further details.

This is a compatibility implementation until the component manifest has been introduced everywhere.

  • return: The property value.
  • deprecated: This function maps to the component Manifest as of 2005-09-08 and should no longer be used directly.
mixed get_component_property (string $component, int $key)
  • string $component: The component name.
  • int $key: The property being queried.
get_interface_class (line 475)

Returns a reference to an instance of the specified component's interface class. The component is given in $path as a MidCOM path.

Such an instance will be cached by the framework so that only one instance is always active for each component. Missing components will be dynamically loaded into memory.

  • return: A reference to the concept class in question or NULL if the class in question does not yet support the new Interface system.
midcom_baseclasses_components_interface &get_interface_class (string $path)
  • string $path: The component name.
get_midcom_class (line 446)

Returns a reference to an instance of the specified component's MIDCOM class. The component is given in $path as a MidCOM path.

Such an instance will be cached by the framework so that only one instance is always active for each component. Missing components will be dynamically loaded into memory.

  • return: A reference to the concept class in question.
  • deprecated: This has been deprecated in MidCOM 2.4 in favor of the new component interface classes.
mixed &get_midcom_class (string $path)
  • string $path: The component name.
is_core_component (line 1017)

Checks if component is a part of the default MidCOM distribution or an external component

  • access: public
void is_core_component (string $component)
  • string $component: Component to check
is_loaded (line 430)

Returns TRUE if the component identified by the MidCOM path $url is already loaded and available for usage.

  • return: true if it is loaded, false otherwise.
boolean is_loaded (string $path)
  • string $path: The component to be queried.
list_loaded_components (line 625)

Retrieve a list of all loaded components. The Array will contain an unsorted collection of MidCOM Paths.

  • return: List of loaded components
Array list_loaded_components ()
load (line 234)

This function will invoke _load directly. If the loading process is unsuccessful, it will call generate_error.

void load (string $path)
  • string $path: The component to load explicitly.
load_all (line 650)

This function tries to load all available components by traversing

the complete(!) Snippetdir Tree. Note, that this might take some time, so use it carefully. After this function returns you can get a list of all available and valid component paths' through list_loaded_components. It will only query the root snippetdirs matching the known top-level-domains (two-letter ones, com, net, org, name, biz, museum). This is done to speed up processing as Asgard or Nemein.Net for example clutter the SG0 with lots of snippetdirs that are no MidCOM components. Note that the load_all command also iterates through the MidCOM tree.

Important note: With the introduction of the component manifest system, calling load_all should no longer be necessary, as (as far as I think) all issues which originally required load_all can be resolved using the manifest. If you think you have found a case where this is not true, please contact the developers on the MidCOM list.

void load_all ()
load_all_manifests (line 684)

This function is called during system startup and loads all component manifests from the disk. The list of manifests to load is determined using a find shell call and is cached using the phpscripts cache module.

This method is executed during system startup by the framework. Other parts of the system must not access it.

void load_all_manifests ()
load_graceful (line 249)

This function will invoke _load directly. If the loading process is unsuccessful, false is returned.

  • return: Indicating success.
boolean load_graceful (string $path)
  • string $path: The component to load explicitly.
load_manifest (line 759)

Load a manifest from the disk and add it to the $manifests list.

It already does all necessary registration work:

  • All default privileges are made known
  • All defined DBA class sets are loaded. If an error occurs here, the manifest will be ignored and an error is logged.

void load_manifest (object $manifest)
  • object $manifest: the manifest object to load.
path_to_prefix (line 563)

Helper, converting a component path (net.nehmer.blog) to a class prefix (net_nehmer_blog).

  • return: Converted string.
string path_to_prefix (string $path)
  • string $path: Input string.
path_to_snippetpath (line 539)

Helper, converting a component path (net.nehmer.blog) to a snippetpath (/net/nehmer/blog).

  • return: Converted string.
string path_to_snippetpath (string $path)
  • string $path: Input string.
process_pending_notifies (line 884)

This function processes all pending notifies and flushes the pending list.

It is called automatically during MidCOM shutdown at the end of the request.

All Notifies for objects which can't be refreshed will be ignored silently (but logged of course). Deleted objects are of course not refreshed.

This function can only be called once during a request.

void process_pending_notifies ()
snippetpath_to_prefix (line 551)

Helper, converting a snippetpath (/net/nehmer/blog) to a class prefix (net_nehmer_blog).

  • return: Converted string.
string snippetpath_to_prefix (string $snippetpath)
  • string $snippetpath: Input string.
trigger_watches (line 830)

This is called by the framework whenever watchable events occur.

The object referenced by $object may be null where appropriate for the operation in question, it is not taken by reference.

Call this only if the operation in question has completed successfully.

The component handlers can safely assume that it is only called once per object and operation at the end of the request.

This latter fact is important to understand: Watches are not executed immediately, instead, they are collected throughout the request and executed during midcom_application::finish() exactly once per instance. The instance is refreshed before it is actually sent to the watchers using a refresh member function unless the object has been deleted, then there will be no refresh attempt.

An instance in this respect is a unique combination of class type and guid values.

A watchable object must therefore have the following properties:

  • string $guid The guid identifying the object.
  • boolean refresh() A method used to refresh the object against its datasource.
So, two instances are equal if and only if they are of the same class and have the same $guid property value.

void trigger_watches (int $operation, mixed $object)
  • int $operation: The operation that has occurred.
  • mixed $object: The object on which the operation occurred. The system will do is_a checks against any registered class restriction on the watch. The object is not taken by-reference but refreshed before actually executing the hook at the end of the request.
validate_path (line 577)

validate_path is used to validate the component located at the snippetdir Path $snippetpath. This is a fully qualified snippetdir path to the component in question.

  • return: True if valid, false otherwise.
  • todo: Currently partly disabled due to the FS-Transition.
boolean validate_path (string $snippetpath)
  • string $snippetpath: The path to be checked.
validate_url (line 603)

Will validate the given MidCOM Path $path for syntactical

correctness. Currently this is a RegEx check that checks for invalid characters in $path, so validate_url does explicitly not check whether the referenced component does exist and whether it is structurally valid.

  • return: True if valid, false otherwise.
boolean validate_url (string $path)
  • string $path: The path to be checked.
_generate_class_manifest_cache (line 714)

This function is called from the class manifest loader in case of a cache miss.

  • todo: investigate if we should unset the package.xml part of the arrays and serialize them
void _generate_class_manifest_cache (string $cache_identifier)
  • string $cache_identifier: The cache identifier to use to cache the manifest loading queue.

Documentation generated on Fri, 10 Oct 2008 22:15:22 +0300 by phpDocumentor 1.4.2