entity_agree-2.0.x-dev/src/Plugin/entity_agree/AgreementHandler/NotificationBlock.php

src/Plugin/entity_agree/AgreementHandler/NotificationBlock.php
<?php

namespace Drupal\entity_agree\Plugin\entity_agree\AgreementHandler;

use Drupal\Core\Form\FormStateInterface;
use Drupal\entity_agree\AgreementHandlerPluginBase;

/**
 * Plugin to display an agreement prompt in a block.
 *
 * @AgreementHandler(
 *   id = "entity_agree_notification_block",
 *   label = @Translation("Notification block"),
 *   category = @Translation("Notify"),
 * )
 */
class NotificationBlock extends AgreementHandlerPluginBase {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'new' => ['value' => '', 'format' => ''],
      'updated' => ['value' => '', 'format' => ''],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form['new'] = [
      '#type' => 'text_format',
      '#title' => $this->t('New'),
      '#description' => $this->t('Message when the user has not yet accepted the agreement.'),
      '#default_value' => $this->configuration['new']['value'],
      '#format' => $this->configuration['new']['format'],
      '#required' => TRUE,
    ];

    $form['updated'] = [
      '#type' => 'text_format',
      '#title' => $this->t('Updated'),
      '#description' => $this->t('Message to the user when the agreement has been updated.'),
      '#default_value' => $this->configuration['updated']['value'],
      '#format' => $this->configuration['updated']['format'],
      '#required' => TRUE,
    ];

    return parent::buildConfigurationForm($form, $form_state);
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc