You are here

class ViewsBadge in Link Badges 8

Same name in this branch
  1. 8 src/Plugin/LinkBadge/ViewsBadge.php \Drupal\link_badges\Plugin\LinkBadge\ViewsBadge
  2. 8 src/Plugin/Derivative/ViewsBadge.php \Drupal\link_badges\Plugin\Derivative\ViewsBadge

Views-based Link Badges

Hierarchy

Expanded class hierarchy of ViewsBadge

File

src/Plugin/Derivative/ViewsBadge.php, line 11

Namespace

Drupal\link_badges\Plugin\Derivative
View source
class ViewsBadge extends DeriverBase {

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $badge_views = Views::getApplicableViews('uses_link_badge');
    foreach ($badge_views as $data) {
      list($view_id, $display_id) = $data;
      $view = Views::getView($view_id);
      $display = $view
        ->getDisplay($display_id);
      $id = $view->storage
        ->id() . ':' . $display_id;
      $this->derivatives[$id] = $base_plugin_definition;
      $this->derivatives[$id] += array(
        'properties' => array(
          'name' => $view->storage
            ->id(),
          'display_id' => $display_id,
        ),
        'label' => $view->storage
          ->label() . ': ' . $display->options['title'],
      );
    }
    return $this->derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
ViewsBadge::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions