abstract class EntityLegalPluginBase in Entity Legal 3.0.x
Same name and namespace in other branches
- 8.2 src/EntityLegalPluginBase.php \Drupal\entity_legal\EntityLegalPluginBase
- 4.0.x src/EntityLegalPluginBase.php \Drupal\entity_legal\EntityLegalPluginBase
Class ResponsiveMenusPluginBase.
@package Drupal\responsive_menus
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface- class \Drupal\entity_legal\EntityLegalPluginBase implements EntityLegalPluginInterface
 
Expanded class hierarchy of EntityLegalPluginBase
4 files declare their use of EntityLegalPluginBase
- Message.php in src/Plugin/ EntityLegal/ Message.php 
- Popup.php in src/Plugin/ EntityLegal/ Popup.php 
- ProfileForm.php in src/Plugin/ EntityLegal/ ProfileForm.php 
- Redirect.php in src/Plugin/ EntityLegal/ Redirect.php 
File
- src/EntityLegalPluginBase.php, line 12 
Namespace
Drupal\entity_legalView source
abstract class EntityLegalPluginBase extends PluginBase implements EntityLegalPluginInterface {
  /**
   * The legal documents that implement this plugin.
   *
   * @var array
   */
  protected $documents = [];
  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->documents = $this
      ->getDocumentsForMethod();
  }
  /**
   * Get all Entity Legal Documents for this plugin.
   *
   * @return array
   *   All published entity legal documents required.
   */
  public function getDocumentsForMethod() {
    // Entity Legal administrators should never be forced to accept documents.
    if (\Drupal::currentUser()
      ->hasPermission('administer entity legal')) {
      return [];
    }
    // Ensure the correct user context for this plugin.
    if ($this->pluginDefinition['type'] == 'existing_users' && \Drupal::currentUser()
      ->isAnonymous()) {
      return [];
    }
    // Get all active documents that must be agreed to.
    $properties = [
      'require_existing' => 1,
    ];
    if ($this->pluginDefinition['type'] == 'new_users') {
      $properties = [
        'require_signup' => 1,
      ];
    }
    $documents = \Drupal::entityTypeManager()
      ->getStorage(ENTITY_LEGAL_DOCUMENT_ENTITY_NAME)
      ->loadByProperties($properties);
    // Remove any documents from the array set that don't use the given
    // acceptance method.
    /** @var \Drupal\entity_legal\EntityLegalDocumentInterface $document */
    foreach ($documents as $name => $document) {
      $agreed = !$document
        ->userMustAgree($this->pluginDefinition['type'] == 'new_users') || $document
        ->userHasAgreed();
      $is_method = $document
        ->getAcceptanceDeliveryMethod($this->pluginDefinition['type'] == 'new_users') == $this->pluginId;
      if ($agreed || !$is_method) {
        unset($documents[$name]);
      }
    }
    return $documents;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| EntityLegalPluginBase:: | protected | property | The legal documents that implement this plugin. | |
| EntityLegalPluginBase:: | public | function | Get all Entity Legal Documents for this plugin. | |
| EntityLegalPluginBase:: | public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: | 1 | 
| EntityLegalPluginInterface:: | public | function | Execute callback for Entity Legal method plugin. | 4 | 
| PluginBase:: | protected | property | Configuration information passed into the plugin. | 1 | 
| PluginBase:: | protected | property | The plugin implementation definition. | 1 | 
| PluginBase:: | protected | property | The plugin_id. | |
| PluginBase:: | constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
| PluginBase:: | public | function | Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: | |
| PluginBase:: | public | function | Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: | |
| PluginBase:: | public | function | Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: | 2 | 
| PluginBase:: | public | function | Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: | |
| PluginBase:: | public | function | Determines if the plugin is configurable. | 
