Same filename in this branch
  1. 4.x src/Plugin/Derivative/QuickTabsBlock.php
Same filename and directory in other branches
  1. 8.x-3.x src/Plugin/Block/QuickTabsBlock.php 1 comment
  2. 8.x-3.x src/Plugin/Derivative/QuickTabsBlock.php 1 comment

Namespace

Drupal\quicktabs\Plugin\Block

File

src/Plugin/Block/QuickTabsBlock.php

View source
<?php

namespace Drupal\quicktabs\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides a 'QuickTabs' block.
 *
 * @Block(
 *   id = "quicktabs_block",
 *   admin_label = @Translation("QuickTabs Block"),
 *   category = @Translation("QuickTabs"),
 *   deriver = "Drupal\quicktabs\Plugin\Derivative\QuickTabsBlock"
 * )
 */
class QuickTabsBlock extends BlockBase implements ContainerFactoryPluginInterface {
    
    /**
     * The entity type manager.
     *
     * @var \Drupal\Core\Entity\EntityTypeManagerInterface
     */
    protected $entityTypeManager;
    
    /**
     * Constructs a BlockComponentRenderArray object.
     *
     * @param array $configuration
     *   A configuration array containing information about the plugin instance.
     * @param string $plugin_id
     *   The plugin ID for the plugin instance.
     * @param mixed $plugin_definition
     *   The plugin implementation definition.
     * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
     *   The entity type manager.
     */
    public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
        parent::__construct($configuration, $plugin_id, $plugin_definition);
        $this->entityTypeManager = $entity_type_manager;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
        return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity_type.manager'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function build() {
        $qt_id = $this->getDerivativeId();
        $qt = $this->entityTypeManager
            ->getStorage('quicktabs_instance')
            ->load($qt_id);
        return $qt->getRenderArray();
    }

}

Classes

Title Deprecated Summary
QuickTabsBlock Provides a 'QuickTabs' block.