Perforce Chronicle 2012.2/486814
API Documentation
|
Defines a page type handler which provides management details for a particular zend navigation container type. More...
Public Member Functions | |
getFormCallback () | |
Retrieve the form callback for this type. | |
getLabel () | |
Get the human-friendly label for this page type handler. | |
isValid () | |
Verifies the current model has a valid className (id). | |
prepareForm (P4Cms_Form $form) | |
Give form callback an oportunity to modify the passed form. | |
setFormCallback ($callback) | |
Set a form callback for this type. | |
setLabel ($label) | |
Set the human-friendly label for this page type handler. | |
Static Public Member Functions | |
static | fetch ($class) |
Get an instance of the appropriate page handler for the specified class. | |
static | fetchAll () |
Get all of the valid page type handlers that are available across all modules. | |
Static Protected Attributes | |
static | $_fields |
static | $_idField = 'id' |
Defines a page type handler which provides management details for a particular zend navigation container type.
static P4Cms_Navigation_PageTypeHandler::fetch | ( | $ | class | ) | [static] |
Get an instance of the appropriate page handler for the specified class.
string | object | $class | the page class to get a handler for. |
{ // normalize input to a string if (!is_string($class)) { $class = get_class($class); } // look for the corresponding handler. $handlers = static::fetchAll(); if (isset($handlers[$class])) { return $handlers[$class]; } // no matching handler, return a generic handler. return new static(array('id' => $class)); }
static P4Cms_Navigation_PageTypeHandler::fetchAll | ( | ) | [static] |
Get all of the valid page type handlers that are available across all modules.
p4cms.navigation.pageTypeHandlers Return a P4Cms_Navigation_PageTypeHandler (or array of Page Type Handlers) to be included in the page type handler fetchAll results. The last subscriber to return a valid entry for a given ID wins. Page type handlers can provide custom page types for use in navigation hierarchies.
{ $handlers = new P4Cms_Model_Iterator; $feedback = P4Cms_PubSub::publish('p4cms.navigation.pageTypeHandlers'); foreach ($feedback as $providedHandlers) { // normalize result to always be an array if (!is_array($providedHandlers)) { $providedHandlers = array($providedHandlers); } foreach ($providedHandlers as $handler) { if ($handler instanceof static && $handler->isValid()) { $handlers[$handler->getId()] = $handler; } } } return $handlers; }
P4Cms_Navigation_PageTypeHandler::getFormCallback | ( | ) |
Retrieve the form callback for this type.
See setFormCallback for more details.
{ return $this->_getValue('formCallback'); }
P4Cms_Navigation_PageTypeHandler::getLabel | ( | ) |
P4Cms_Navigation_PageTypeHandler::isValid | ( | ) |
P4Cms_Navigation_PageTypeHandler::prepareForm | ( | P4Cms_Form $ | form | ) |
Give form callback an oportunity to modify the passed form.
If no callback is present the form is returned unmodified.
P4Cms_Form | $form | The default form to be modified |
{ $callback = $this->getFormCallback(); if (is_callable($callback)) { return $callback($form); } return $form; }
P4Cms_Navigation_PageTypeHandler::setFormCallback | ( | $ | callback | ) |
Set a form callback for this type.
The form callback will be executed by prepareForm to offer type an opportunity to modify the default form.
The callback should expect a P4Cms_Form for its sole argument and must return a P4Cms_Form.
null | callable | $callback | The callback to set or null. |
{ if ($callback !== null && !is_callable($callback)) { throw new InvalidArgumentException('Form callback must be callable or null'); } return $this->_setValue('formCallback', $callback); }
P4Cms_Navigation_PageTypeHandler::setLabel | ( | $ | label | ) |
Set the human-friendly label for this page type handler.
string | $label | the display label for this page type handler. |
{ return $this->_setValue('label', $label); }
P4Cms_Navigation_PageTypeHandler::$_fields [static, protected] |
array( 'label' => array( 'accessor' => 'getLabel', 'mutator' => 'setLabel' ), 'formCallback' => array( 'accessor' => 'getFormCallback', 'mutator' => 'setFormCallback' ) )
Reimplemented from P4Cms_Model.
P4Cms_Navigation_PageTypeHandler::$_idField = 'id' [static, protected] |
Reimplemented from P4Cms_Model.