In short, the Manifest shall contain specific or arbitrary metadata that is useful to any provider or client, as well as be responsible for loading any additional providers into the provider repository.
To introduce metadata into the manifest repository, all one must do
is implement the empty Zend_Tool_Framework_Manifest_Interface,
and provide a getMetadata() method which shall return an array
of objects that implement Zend_Tool_Framework_Manifest_Metadata.
<?php
interface Zend_Tool_Framework_Manifest_Interface
{
public function getMetadata();
}
Metadata objects are loaded (by a loader defined below) into the
Manifest Repository (Zend_Tool_Framework_Manifest_Repository).
Manifests will be processed after all Providers have been found to be
loaded into the provider repository. This shall allow Manifests to
create Metadata objects based on what is currently inside the
provider repository.
There are a few different metadata classes that can be used to
describe metadata. The
Zend_Tool_Framework_Manifest_Metadata is the base
metadata object. As you can see by the following code
snippet, the base metadata class is fairly lightweight and
abstract in nature:
<?php
class Zend_Tool_Framework_Metadata_Basic
{
protected $_type = 'Global';
protected $_name = null;
protected $_value = null;
protected $_reference = null;
public function getType();
public function getName();
public function getValue();
public function getReference();
/** ... */
}
There are other built in metadata classes as well for describing
more specialized metadata: ActionMetadata and
ProviderMetadata. These classes will help you describe
in more detail metadata that is specific to either actions or
providers, and the reference is expected to be a reference to an
action or a provider respectively. These classes are described in
the following code snippet.
<?php
class Zend_Tool_Framework_Manifest_ActionMetadata
extends Zend_Tool_Framework_Manifest_Metadata
{
protected $_type = 'Action';
protected $_actionName = null;
public function getActionName();
/** ... */
}
class Zend_Tool_Framework_Manifest_ProviderMetadata
extends Zend_Tool_Framework_Manifest_Metadata
{
protected $_type = 'Provider';
protected $_providerName = null;
protected $_actionName = null;
protected $_specialtyName = null;
public function getProviderName();
public function getActionName();
public function getSpecialtyName();
/** ... */
}
'Type' in these classes is used to describe the type of metadata the
object is responsible for. In the cases of the
ActionMetadata, the type would be 'Action', and
conversely in the case of the ProviderMetadata the type
is 'Provider'. These metadata types will also include additional
structured information about both the "thing" they are describing as
well as the object (the getReference()) they are
referencing with this new metadata.
In order to create your own metadata type, all one must do is extend
the base Zend_Tool_Framework_Manifest_Metadata class
and return these new metadata objects via a local Manifest
class or object. These user based classes will live in the Manifest
Repository
Once these metadata objects are in the repository, there are then two different methods that can be used in order to search for them in the repository.
<?php
class Zend_Tool_Framework_Manifest_Repository
{
/**
* To use this method to search, $searchProperties should contain the names
* and values of the key/value pairs you would like to match within the
* manifest.
*
* For Example:
* $manifestRepository->findMetadatas(array(
* 'action' => 'Foo',
* 'name' => 'cliActionName'
* ));
*
* Will find any metadata objects that have a key with name 'action' value
* of 'Foo', AND a key named 'name' value of 'cliActionName'
*
* Note: to either exclude or include name/value pairs that exist in the
* search criteria but do not appear in the object, pass a bool value to
* $includeNonExistentProperties
*/
public function findMetadatas(Array $searchProperties = array(),
$includeNonExistentProperties = true);
/**
* The following will return exactly one of the matching search criteria,
* regardless of how many have been returned. First one in the manifest is
* what will be returned.
*/
public function findMetadata(Array $searchProperties = array(),
$includeNonExistentProperties = true)
{
$metadatas = $this->getMetadatas($searchProperties,
$includeNonExistentProperties);
return array_shift($metadatas);
}
}
Looking at the search methods above, the signatures allow for
extremely flexible searching. In order to find a metadata object,
simply pass in an array of matching constraints via an array. If
the data is accessible through the Property accessor (the
getSomething() methods implemented on the metadata
object), then it will be passed back to the user as a "found"
metadata object.




