CustomBlock.php 824 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
<?php

/**
 * @file
 * Contains \Drupal\custom_block\Plugin\Derivative\CustomBlock.
 */

namespace Drupal\custom_block\Plugin\Derivative;

10
use Drupal\Component\Plugin\Derivative\DerivativeBase;
11
use Drupal\Core\Plugin\Discovery\ContainerDerivativeInterface;
12 13 14 15

/**
 * Retrieves block plugin definitions for all custom blocks.
 */
16
class CustomBlock extends DerivativeBase {
17
  /**
18
   * {@inheritdoc}
19
   */
20
  public function getDerivativeDefinitions($base_plugin_definition) {
21 22
    $custom_blocks = entity_load_multiple('custom_block');
    foreach ($custom_blocks as $custom_block) {
23 24
      $this->derivatives[$custom_block->uuid()] = $base_plugin_definition;
      $this->derivatives[$custom_block->uuid()]['admin_label'] = $custom_block->label();
25
    }
26
    return parent::getDerivativeDefinitions($base_plugin_definition);
27 28
  }
}