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_interface_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 than 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:
Verify that the given component is valid in terms of the MidCOM Specification.
Initialize the Component. Check whether all required concept classes exist.
Return the various interface concepts upon each request
from the framework.
Stage 1 will do all basic sanity checking. 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
initialize() which should load everything necessary.
Stage 3 is the final stage where the loader stays in memory in
order to return the loaded component's Interface instances upon request.
In case you need an instance of the component loader to verify or
transform component paths, use midcom::get()->componentloader
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 indexed array stores the MidCOM paths of all loaded
components. Its elements are used as keys for the cache storage.
Type
Array
$_tried_to_load
$_tried_to_load : array
This array contains a list of components that were tried to be loaded.
The components are added to this list even if the system only tried
to load it and failed. This way we protect against duplicate class errors
and the like if a defective class is tried to be loaded twice.
The array maps component names to loading results. The loading result is
either false or true as per the result of the load call.
Returns 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.
Convert a component path (net.nehmer.blog) to a snippetpath (/net/nehmer/blog).
Parameters
string
$component_name
Input string.
Returns
string
—
Converted string.
path_to_prefix()
path_to_prefix(string $path) : string
Convert a component path (net.nehmer.blog) to a class prefix (net_nehmer_blog).
Parameters
string
$path
Input string.
Returns
string
—
Converted string.
list_loaded_components()
list_loaded_components() : Array
Retrieve a list of all loaded components. The Array will contain an
unsorted collection of MidCOM Paths.
Returns
Array
—
List of loaded components
load_all_manifests()
load_all_manifests()
This function is called during system startup and loads all component manifests. The list
of manifests to load is determined using a find shell call and is cached using the memcache
cache module.
This method is executed during system startup by the framework. Other parts of the system
must not access it.
get_manifests()
get_manifests(\midcom_config $config = null)
This function is called from the class manifest loader in case of a cache miss.
Build 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.
Parameters
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.
Returns
Array
—
All found component data indexed by known components.