You are here

class SmsUserMenuLink in SMS Framework 8

Same name and namespace in other branches
  1. 2.x modules/sms_user/src/Plugin/Derivative/SmsUserMenuLink.php \Drupal\sms_user\Plugin\Derivative\SmsUserMenuLink
  2. 2.1.x modules/sms_user/src/Plugin/Derivative/SmsUserMenuLink.php \Drupal\sms_user\Plugin\Derivative\SmsUserMenuLink

Provides dynamic menu links for SMS User.

Hierarchy

Expanded class hierarchy of SmsUserMenuLink

See also

\Drupal\views\Plugin\Menu\ViewsMenuLink

1 string reference to 'SmsUserMenuLink'
sms_user.links.menu.yml in modules/sms_user/sms_user.links.menu.yml
modules/sms_user/sms_user.links.menu.yml

File

modules/sms_user/src/Plugin/Derivative/SmsUserMenuLink.php, line 15

Namespace

Drupal\sms_user\Plugin\Derivative
View source
class SmsUserMenuLink extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The phone number verification service.
   *
   * @var \Drupal\sms\Provider\PhoneNumberVerificationInterface
   */
  protected $phoneNumberVerification;

  /**
   * Constructs a \Drupal\sms_user\Plugin\Derivative\SmsUserMenuLink instance.
   *
   * @param \Drupal\sms\Provider\PhoneNumberVerificationInterface $phone_number_verification
   *   The phone number verification service.
   */
  public function __construct(PhoneNumberVerificationInterface $phone_number_verification) {
    $this->phoneNumberVerification = $phone_number_verification;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('sms.phone_number.verification'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $links = [];
    if ($this->phoneNumberVerification
      ->getPhoneNumberSettings('user', 'user')) {
      $links['sms_user_phone_number_settings'] = [
        'title' => t('User phone number'),
        'description' => t('Set up phone number fields and settings for users.'),
        'route_name' => 'entity.phone_number_settings.edit_form',
        'route_parameters' => [
          'phone_number_settings' => 'user.user',
        ],
        'parent' => 'user.admin_index',
        'weight' => 21,
      ];
    }
    return $links;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
SmsUserMenuLink::$phoneNumberVerification protected property The phone number verification service.
SmsUserMenuLink::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
SmsUserMenuLink::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
SmsUserMenuLink::__construct public function Constructs a \Drupal\sms_user\Plugin\Derivative\SmsUserMenuLink instance.