You are here

private function crumbs_PluginSystem_PluginMethodIterator::setFirstValidIteratorPosition in Crumbs, the Breadcrumbs suite 7.2

Skips through the array of plugins, until a valid position is found, starting from the $pluginKey given as an argument.

Parameters

string|false $pluginKey: The key returned from either next($this->pluginkeys) or from reset($this->pluginKeys). This means the value can be a key or false.

3 calls to crumbs_PluginSystem_PluginMethodIterator::setFirstValidIteratorPosition()
crumbs_PluginSystem_PluginMethodIterator::next in lib/PluginSystem/PluginMethodIterator.php
(PHP 5 &gt;= 5.0.0)<br/> Move forward to next element @link http://php.net/manual/en/iterator.next.php
crumbs_PluginSystem_PluginMethodIterator::rewind in lib/PluginSystem/PluginMethodIterator.php
(PHP 5 &gt;= 5.0.0)<br/> Rewind the Iterator to the first element @link http://php.net/manual/en/iterator.rewind.php
crumbs_PluginSystem_PluginMethodIterator::__construct in lib/PluginSystem/PluginMethodIterator.php

File

lib/PluginSystem/PluginMethodIterator.php, line 105

Class

crumbs_PluginSystem_PluginMethodIterator

Code

private function setFirstValidIteratorPosition($pluginKey) {
  while (TRUE) {
    if ($pluginKey === FALSE) {

      // When next($array) returns false, Iterator::key() should return NULL.
      $this->pluginKey = NULL;
      return;
    }
    if (isset($this->plugins[$pluginKey])) {
      $plugin = $this->plugins[$pluginKey];
      if (method_exists($plugin, $this->pluginMethod)) {
        $this->pluginKey = $pluginKey;
        $this->iteratorPosition = new crumbs_PluginSystem_PluginMethodIteratorPosition($pluginKey, $this->pluginMethod, $plugin);
        return;
      }
    }
    $pluginKey = next($this->pluginKeys);
  }
}