You are here

class WebformCompositeDeriver in Webform Composite Tools 8

Provides webform element reusable custom webform composite elements.

Hierarchy

Expanded class hierarchy of WebformCompositeDeriver

See also

\Drupal\webform_composite\Plugin\WebformElement\WebformReusableComposite

File

src/Plugin/Derivative/WebformCompositeDeriver.php, line 15

Namespace

Drupal\webform_composite\Plugin\Derivative
View source
class WebformCompositeDeriver extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The Reusable Composite storage.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface
   */
  protected $compositeStorage;

  /**
   * Constructs new WebformReusableCompositeDeriver.
   *
   * @param Drupal\Core\Entity\EntityStorageInterface $composite_storage
   *   The Dynamic Composite storage.
   */
  public function __construct(EntityStorageInterface $composite_storage) {
    $this->compositeStorage = $composite_storage;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('entity_type.manager')
      ->getStorage('webform_composite'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $composites = $this->compositeStorage
      ->loadMultiple();
    foreach ($composites as $composite) {
      $this->derivatives[$composite
        ->id()] = $base_plugin_definition;
      $this->derivatives[$composite
        ->id()]['label'] = $composite
        ->label();
    }
    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
WebformCompositeDeriver::$compositeStorage protected property The Reusable Composite storage.
WebformCompositeDeriver::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
WebformCompositeDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
WebformCompositeDeriver::__construct public function Constructs new WebformReusableCompositeDeriver.