You are here

UserMergeActionBase.php in User Merge 2.x

File

src/Plugin/UserMerge/Action/UserMergeActionBase.php
View source
<?php

namespace Drupal\usermerge\Plugin\UserMerge\Action;

use Drupal\Core\Session\AccountInterface;
use Drupal\usermerge\Plugin\UserMergeActionPluginInterface;
use Drupal\Component\Plugin\PluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Class UserMergeActionBase.
 *
 * @package Drupal\usermerge\Plugin\UserMerge\Action
 */
abstract class UserMergeActionBase extends PluginBase implements UserMergeActionPluginInterface {

  /**
   * The current user.
   *
   * @var \Drupal\Core\Session\AccountInterface
   */
  protected $currentUser;

  /**
   * UserMergeActionBase constructor.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Session\AccountInterface $current_user
   *   The current user.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, AccountInterface $current_user) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->currentUser = $current_user;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('current_user'));
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return $this->pluginDefinition['name'];
  }

}

Classes

Namesort descending Description
UserMergeActionBase Class UserMergeActionBase.