ds-8.x-3.9/src/Plugin/DsField/User/UserSignature.php

src/Plugin/DsField/User/UserSignature.php
<?php

namespace Drupal\ds\Plugin\DsField\User;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\ds\Attribute\DsField;
use Drupal\ds\Plugin\DsField\Markup;

/**
 * Plugin that renders the user signature.
 */
#[DsField(
  id: 'user_signature',
  title: new TranslatableMarkup('User signature'),
  entity_type: 'user',
  provider: 'user'
)]
class UserSignature extends Markup {

  /**
   * {@inheritdoc}
   */
  public function key() {
    return 'signature';
  }

  /**
   * {@inheritdoc}
   */
  public function format() {
    return 'signature_format';
  }

  /**
   * {@inheritdoc}
   */
  public function isAllowed() {
    // Checks if user signatures are enabled.
    $user_signatures = \Drupal::config('user.settings')->get('signatures');

    // We use this function to decide if we should show this field.
    // When user signatures are disabled we should ignore this.
    if (!empty($user_signatures)) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }

}

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

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