You are here

class _crumbs_InvokeAction_define in Crumbs, the Breadcrumbs suite 6.2

This class uses the InvokeAction pattern, but it does not implement any of the InvokeAction interfaces. This is because it is not supposed to be used with the PluginEngine, but rather from a custom function (see above).

Hierarchy

Expanded class hierarchy of _crumbs_InvokeAction_define

File

./crumbs.admin.inc, line 195

View source
class _crumbs_InvokeAction_define {
  protected $_keys = array(
    '*' => TRUE,
  );
  protected $_keysByPlugin = array();
  protected $_pluginKey;
  protected $_definitionHandler_one;
  protected $_definitionHandler_many;
  function __construct() {
    $this->_definitionHandler_one = new _crumbs_PluginDefinitionHandler_one($this);
    $this->_definitionHandler_many = new _crumbs_PluginDefinitionHandler_many($this);
  }
  function invoke($plugin, $plugin_key) {
    $this->_pluginKey = $plugin_key;
    if (method_exists($plugin, 'defineOne')) {
      $plugin
        ->defineOne($this->_definitionHandler_one);
    }
    if (method_exists($plugin, 'define')) {
      $plugin
        ->define($this->_definitionHandler_many);
    }
    if (method_exists($plugin, 'defineMany')) {
      $plugin
        ->defineMany($this->_definitionHandler_many);
    }
  }
  function addRule($key_suffix, $title) {
    $this
      ->_addRule($this->_pluginKey . '.' . $key_suffix, $title);
  }
  function setTitle($title) {
    $this
      ->_addRule($this->_pluginKey, $title);
  }
  protected function _addRule($key, $title) {
    $fragments = explode('.', $key);
    $partial_key = array_shift($fragments);
    while (TRUE) {
      if (empty($fragments)) {
        break;
      }
      $wildcard_key = $partial_key . '.*';
      $this->_keys[$wildcard_key] = TRUE;
      $this->_keysByPlugin[$this->_pluginKey][$wildcard_key] = TRUE;
      $partial_key .= '.' . array_shift($fragments);
    }
    $this->_keys[$key] = $title;
    $this->_keysByPlugin[$this->_pluginKey][$key] = $title;
  }
  function getKeys() {
    return $this->_keys;
  }
  function getKeysByPlugin() {
    return $this->_keysByPlugin;
  }

}

Members