You are here

class ConfigDeriver in Payment 8.2

Derives payment status plugin definitions based on configuration entities.

Hierarchy

Expanded class hierarchy of ConfigDeriver

1 file declares its use of ConfigDeriver
ConfigDeriverTest.php in tests/src/Unit/Plugin/Payment/Status/ConfigDeriverTest.php
1 string reference to 'ConfigDeriver'
payment.payment.status.yml in ./payment.payment.status.yml
payment.payment.status.yml

File

src/Plugin/Payment/Status/ConfigDeriver.php, line 13

Namespace

Drupal\payment\Plugin\Payment\Status
View source
class ConfigDeriver extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The payment status storage controller.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface
   */
  protected $paymentStatusStorage;

  /**
   * Constructs a new instance.
   */
  public function __construct(EntityStorageInterface $payment_status_storage) {
    $this->paymentStatusStorage = $payment_status_storage;
  }

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

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {

    /** @var \Drupal\payment\Entity\PaymentStatusInterface[] $statuses */
    $statuses = $this->paymentStatusStorage
      ->loadMultiple();
    foreach ($statuses as $status) {
      $this->derivatives[$status
        ->id()] = array(
        'description' => $status
          ->getDescription(),
        'label' => $status
          ->label(),
        'parent_id' => $status
          ->getParentId(),
      ) + $base_plugin_definition;
    }
    return parent::getDerivativeDefinitions($base_plugin_definition);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigDeriver::$paymentStatusStorage protected property The payment status storage controller.
ConfigDeriver::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
ConfigDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
ConfigDeriver::__construct public function Constructs a new instance.
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition