You are here

class SelectionBase in Multi-path autocomplete 8

Same name in this branch
  1. 8 lib/Drupal/mpac/Plugin/Derivative/SelectionBase.php \Drupal\mpac\Plugin\Derivative\SelectionBase
  2. 8 lib/Drupal/mpac/Plugin/mpac/selection/SelectionBase.php \Drupal\mpac\Plugin\mpac\selection\SelectionBase

Base class for selection plugins provided by Multi-path autocomplete.

Hierarchy

  • class \Drupal\mpac\Plugin\Derivative\SelectionBase implements \Drupal\Component\Plugin\Derivative\DerivativeInterface

Expanded class hierarchy of SelectionBase

File

lib/Drupal/mpac/Plugin/Derivative/SelectionBase.php, line 15
Contains \Drupal\mpac\Plugin\Derivative\SelectionBase.

Namespace

Drupal\mpac\Plugin\Derivative
View source
class SelectionBase implements DerivativeInterface {

  /**
   * Holds the list of plugin derivatives.
   *
   * @var array
   */
  protected $derivatives = array();

  /**
   * Implements DerivativeInterface::getDerivativeDefinition().
   */
  public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) {
    if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) {
      return $this->derivatives[$derivative_id];
    }
    $this
      ->getDerivativeDefinitions($base_plugin_definition);
    return $this->derivatives[$derivative_id];
  }

  /**
   * Implements DerivativeInterface::getDerivativeDefinitions().
   */
  public function getDerivativeDefinitions(array $base_plugin_definition) {
    $supported_types = array(
      'path',
      'shortcut',
    );
    foreach (mpac_selection_plugin_info() as $type => $info) {
      if (!in_array($type, $supported_types)) {
        $this->derivatives[$type] = $base_plugin_definition;
        $this->derivatives[$type]['label'] = t('@type selection', array(
          '@type' => $info['label'],
        ));
      }
    }
    return $this->derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SelectionBase::$derivatives protected property Holds the list of plugin derivatives.
SelectionBase::getDerivativeDefinition public function Implements DerivativeInterface::getDerivativeDefinition().
SelectionBase::getDerivativeDefinitions public function Implements DerivativeInterface::getDerivativeDefinitions().