View source  
  <?php
namespace Drupal\blocktabs;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\ContextAwarePluginBase;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class TabBase extends ContextAwarePluginBase implements TabInterface, ContainerFactoryPluginInterface {
  
  protected $uuid;
  
  protected $weight = '';
  
  protected $title = '';
  
  protected $logger;
  
  public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerInterface $logger) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this
      ->setConfiguration($configuration);
    $this->logger = $logger;
  }
  
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('logger.factory')
      ->get('blocktabs'));
  }
  
  public function getDerivativeExtension($extension) {
    
    return $extension;
  }
  
  public function getSummary() {
    return [
      '#markup' => '',
      '#tab' => [
        'id' => $this->pluginDefinition['id'],
        'label' => $this
          ->label(),
        'description' => $this->pluginDefinition['description'],
      ],
    ];
  }
  
  public function label() {
    return $this->title;
  }
  
  public function getUuid() {
    return $this->uuid;
  }
  
  public function setWeight($weight) {
    $this->weight = $weight;
    return $this;
  }
  
  public function getWeight() {
    return $this->weight;
  }
  
  public function setTitle($title) {
    $this->title = $title;
    return $this;
  }
  
  public function getTitle() {
    return $this->title;
  }
  
  public function getConfiguration() {
    return [
      'uuid' => $this
        ->getUuid(),
      'id' => $this
        ->getPluginId(),
      'title' => $this
        ->getTitle(),
      'weight' => $this
        ->getWeight(),
      'data' => $this->configuration,
    ];
  }
  
  public function setConfiguration(array $configuration) {
    $configuration += [
      'data' => [],
      'uuid' => '',
      'title' => '',
      'weight' => '',
    ];
    $this->configuration = $configuration['data'] + $this
      ->defaultConfiguration();
    $this->uuid = $configuration['uuid'];
    $this->title = $configuration['title'];
    $this->weight = $configuration['weight'];
    return $this;
  }
  
  public function defaultConfiguration() {
    return [];
  }
  
  public function calculateDependencies() {
    return [];
  }
  
  public function getContent() {
    $tab_content = '';
    return $tab_content;
  }
}