You are here

public function WebformElementBase::displayDisabledWarning in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElementBase.php \Drupal\webform\Plugin\WebformElementBase::displayDisabledWarning()

Display element disabled warning.

Parameters

array $element: An element.

Overrides WebformElementInterface::displayDisabledWarning

2 calls to WebformElementBase::displayDisabledWarning()
WebformElementBase::prepare in src/Plugin/WebformElementBase.php
Prepare an element to be rendered within a webform.
WebformManagedFileBase::displayDisabledWarning in src/Plugin/WebformElement/WebformManagedFileBase.php
Display element disabled warning.
1 method overrides WebformElementBase::displayDisabledWarning()
WebformManagedFileBase::displayDisabledWarning in src/Plugin/WebformElement/WebformManagedFileBase.php
Display element disabled warning.

File

src/Plugin/WebformElementBase.php, line 1260

Class

WebformElementBase
Provides a base class for a webform element.

Namespace

Drupal\webform\Plugin

Code

public function displayDisabledWarning(array $element) {
  $t_args = [
    '%title' => $this
      ->getLabel($element),
    '%type' => $this
      ->getPluginLabel(),
    ':href' => Url::fromRoute('webform.config.elements')
      ->toString(),
  ];
  if ($this->currentUser
    ->hasPermission('administer webform')) {
    $message = $this
      ->t('%title is a %type element, which has been disabled and will not be rendered. Go to the <a href=":href">admin settings</a> page to enable this element.', $t_args);
  }
  else {
    $message = $this
      ->t('%title is a %type element, which has been disabled and will not be rendered. Please contact a site administrator.', $t_args);
  }
  $this
    ->messenger()
    ->addWarning($message);
  $context = [
    '@title' => $this
      ->getLabel($element),
    '@type' => $this
      ->getPluginLabel(),
    'link' => Link::fromTextAndUrl($this
      ->t('Edit'), Url::fromRoute('<current>'))
      ->toString(),
  ];
  $this->logger
    ->notice("'@title' is a '@type' element, which has been disabled and will not be rendered.", $context);
}