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:
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)
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.
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.
Get list of component and its dependencies depend on
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.
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.
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.
Checks if component is a part of the default MidCOM distribution or an external component
Returns TRUE if the component identified by the MidCOM path $url is already loaded and available for usage.
Retrieve a list of all loaded components. The Array will contain an unsorted collection of MidCOM Paths.
This function will invoke _load directly. If the loading process is unsuccessful, it will call generate_error.
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.
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.
This function will invoke _load directly. If the loading process is unsuccessful, false is returned.
Load a manifest from the disk and add it to the $manifests list.
It already does all necessary registration work:
Helper, converting a component path (net.nehmer.blog) to a class prefix (net_nehmer_blog).
Helper, converting a component path (net.nehmer.blog) to a snippetpath (/net/nehmer/blog).
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.
Helper, converting a snippetpath (/net/nehmer/blog) to a class prefix (net_nehmer_blog).
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:
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.
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.
This function is called from the class manifest loader in case of a cache miss.
Documentation generated on Fri, 10 Oct 2008 22:15:22 +0300 by phpDocumentor 1.4.2