You are here

class InviteBlock in Invite 8

InviteBlock Class.

Hierarchy

Expanded class hierarchy of InviteBlock

File

src/Plugin/Derivative/InviteBlock.php, line 11

Namespace

Drupal\invite\Plugin\Derivative
View source
class InviteBlock implements DeriverInterface {

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
    $derivatives = $this
      ->getDerivativeDefinitions($base_plugin_definition);
    if (isset($derivatives[$derivative_id])) {
      return $derivatives[$derivative_id];
    }
  }

  /**
   * Creates a block for each sending method that is enabled on invite_types.
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $derivatives = [];
    foreach (InviteSender::loadMultiple(\Drupal::entityQuery('invite_sender')
      ->condition('sending_methods', $base_plugin_definition['provider'], 'CONTAINS')
      ->execute()) as $sending_method) {
      $sending_method_id = $sending_method
        ->id();
      $derivatives[$sending_method_id] = $base_plugin_definition;
      $derivatives[$sending_method_id]['admin_label'] = \Drupal::config('invite.invite_type.' . $sending_method_id)
        ->get('label');
    }
    return $derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
InviteBlock::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
InviteBlock::getDerivativeDefinitions public function Creates a block for each sending method that is enabled on invite_types. Overrides DeriverInterface::getDerivativeDefinitions