You are here

abstract class PushBase in Open Social 8.9

Same name and namespace in other branches
  1. 8.7 modules/custom/activity_send/modules/activity_send_push_notification/src/PushBase.php \Drupal\activity_send_push_notification\PushBase
  2. 8.8 modules/custom/activity_send/modules/activity_send_push_notification/src/PushBase.php \Drupal\activity_send_push_notification\PushBase
  3. 10.3.x modules/custom/activity_send/modules/activity_send_push_notification/src/PushBase.php \Drupal\activity_send_push_notification\PushBase
  4. 10.0.x modules/custom/activity_send/modules/activity_send_push_notification/src/PushBase.php \Drupal\activity_send_push_notification\PushBase
  5. 10.1.x modules/custom/activity_send/modules/activity_send_push_notification/src/PushBase.php \Drupal\activity_send_push_notification\PushBase
  6. 10.2.x modules/custom/activity_send/modules/activity_send_push_notification/src/PushBase.php \Drupal\activity_send_push_notification\PushBase

Class PushBase.

@package Drupal\activity_send_push_notification

Hierarchy

Expanded class hierarchy of PushBase

File

modules/custom/activity_send/modules/activity_send_push_notification/src/PushBase.php, line 17

Namespace

Drupal\activity_send_push_notification
View source
abstract class PushBase extends PluginBase implements PushInterface {
  use StringTranslationTrait;

  /**
   * The configuration factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * The current active user ID.
   *
   * @var int
   */
  protected $currentUserId;

  /**
   * Constructs a PushBase object.
   *
   * @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\StringTranslation\TranslationInterface $string_translation
   *   The string translation service.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The configuration factory.
   * @param int $current_user_id
   *   The current active user ID.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, TranslationInterface $string_translation, ConfigFactoryInterface $config_factory, $current_user_id) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this
      ->setStringTranslation($string_translation);
    $this->configFactory = $config_factory;
    $this->currentUserId = $current_user_id;
  }

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

  /**
   * {@inheritdoc}
   */
  public function access() {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm() {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(FormStateInterface $form_state) {
  }

  /**
   * Returns the submitted form value for a specific key.
   *
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state.
   * @param string|array $key
   *   Values are stored as a multi-dimensional associative array. If $key is a
   *   string, it will return $values[$key]. If $key is an array, each element
   *   of the array will be used as a nested key. If $key = array('foo', 'bar')
   *   it will return $values['foo']['bar'].
   * @param mixed $default
   *   (optional) The default value if the specified key does not exist.
   *
   * @return mixed
   *   The value for the given key, or NULL.
   */
  protected function getFormValue(FormStateInterface $form_state, $key, $default = NULL) {
    if (!is_array($key)) {
      $key = [
        $key,
      ];
    }
    $key = array_merge([
      'push_notifications',
      $this
        ->getPluginId(),
    ], $key);
    return $form_state
      ->getValue($key, $default);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PushBase::$configFactory protected property The configuration factory.
PushBase::$currentUserId protected property The current active user ID.
PushBase::access public function Check access. Overrides PushInterface::access
PushBase::buildForm public function Build form elements. Overrides PushInterface::buildForm
PushBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
PushBase::getFormValue protected function Returns the submitted form value for a specific key.
PushBase::submitForm public function Save plugin settings. Overrides PushInterface::submitForm
PushBase::__construct public function Constructs a PushBase object. Overrides PluginBase::__construct
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.