$__object
$__object : \midcom_core_dbaobject
Object to which we are attached to. This object can be accessed from the outside, where necessary.
This class is an interface to the metadata of MidCOM objects.
It will use an internal mechanism to cache repeated accesses to the same metadata key during its lifetime. (Invalidating this cache will be possible though.)
Metadata Key Reference
See the schema in /midcom/config/metadata_default.inc
Example Usage, Metadata Retrieval
<?php
$nap = new midcom_helper_nav();
$node = $nap->get_node($nap->get_current_node());
$meta = midcom_helper_metadata::retrieve($node[MIDCOM_NAV_GUID]); echo "Visible : " . $meta->is_visible() . ""; echo "Approved : " . $meta->is_approved() . ""; echo "Keywords: " . $meta->get('keywords') . "";
Example Usage, Approval
<?php
$article = new midcom_db_article($my_article_created_id);
$meta = midcom_helper_metadata::retrieve($article); $meta->approve();
$__object : \midcom_core_dbaobject
Object to which we are attached to. This object can be accessed from the outside, where necessary.
$_datamanager : \midcom\datamanager\datamanager
Datamanager instance for the given object.
__construct(\midcom_core_dbaobject $object, string $schemadb)
This will construct a new metadata object for an existing content object.
You must never use this constructor directly, it is considered private in this respect. Instead, use the retrieve method, which may be called as a class method.
You may use objects derived from any MidgardObject will do as well as long as the parameter call is available normally.
\midcom_core_dbaobject | $object | The MidgardObject to attach to. |
string | $schemadb | The URL of the schemadb to use. |
get(string $key) : mixed
Return a single metadata key from the object. The return type depends on the metadata key that is requested (see the class introduction).
You will not get the data from the datamanager using this calls, but the only slightly post-processed metadata values. See _retrieve_value for post processing.
string | $key | The key to retrieve |
The key's value.
get_datamanager() : \midcom\datamanager\datamanager
Return a Datamanager instance for the current object.
Also, whenever the containing datamanager stores its data, you must call the on_update() method of this class. This is very important or backwards compatibility will be broken.
A initialized Datamanager instance for the selected object.
is_object_visible_onsite() : boolean
This is a helper function which indicates whether a given object may be shown onsite taking approval, scheduling and visibility settings into account. The important point here is that it also checks the global configuration defaults, so that this is basically the same base on which NAP decides whether to show an item or not.
Indicating visibility.
retrieve(mixed $source) : \midcom_helper_metadata
Returns a metadata object for a given content object.
You may bass any one of the following arguments to the function:
mixed | $source | The object to attach to, this may be either a MidgardObject, a GUID or a NAP data structure (node or leaf). |
The created metadata object.
find_schemaname(\midcom\datamanager\schemadb $schemadb, \midcom_core_dbaobject $object) : string
Determine the schema to use for a particular object
\midcom\datamanager\schemadb | $schemadb | The schema DB |
\midcom_core_dbaobject | $object | the object to work on |
The schema name
_set_property(string $key, mixed $value)
Directly set a metadata option.
The passed value will be stored using the follow transformations:
Any error will trigger midcom_error.
string | $key | The key to set. |
mixed | $value | The value to set. |
on_update(string $key = false)
This is the update event handler for the Metadata system. It must be called whenever metadata changes to synchronize the various backwards-compatibility values in place throughout the system.
string | $key | The key that was updated. Leave empty for a complete update by the Datamanager. |
_retrieve_value(string $key)
Retrieves a given metadata key, postprocesses it where necessary and stores it into the local cache.
Note, that we hide any errors from not existent properties explicitly, as a few of the MidCOM objects do not support all of the predefined meta data fields, PHP will default to "0" in these cases. For Person IDs, this "0" is rewritten to "1" to use the MidgardAdministrator account instead.
string | $key | The key to retrieve. |