You are here

public function YamlFormElementBase::displayDisabledWarning in YAML Form 8

Display element disabled warning.

Parameters

array $element: An element.

Overrides YamlFormElementInterface::displayDisabledWarning

2 calls to YamlFormElementBase::displayDisabledWarning()
YamlFormElementBase::prepare in src/YamlFormElementBase.php
Prepare an element to be rendered within a form.
YamlFormManagedFileBase::displayDisabledWarning in src/Plugin/YamlFormElement/YamlFormManagedFileBase.php
Display element disabled warning.
1 method overrides YamlFormElementBase::displayDisabledWarning()
YamlFormManagedFileBase::displayDisabledWarning in src/Plugin/YamlFormElement/YamlFormManagedFileBase.php
Display element disabled warning.

File

src/YamlFormElementBase.php, line 508

Class

YamlFormElementBase
Provides a base class for a form element.

Namespace

Drupal\yamlform

Code

public function displayDisabledWarning(array $element) {
  $t_args = [
    '%title' => $this
      ->getLabel($element),
    '%type' => $this
      ->getPluginLabel(),
    ':href' => Url::fromRoute('yamlform.settings')
      ->setOption('fragment', 'edit-elements')
      ->toString(),
  ];
  if ($this->currentUser
    ->hasPermission('administer yamlform')) {
    $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);
  }
  drupal_set_message($message, 'warning');
  $context = [
    '@title' => $this
      ->getLabel($element),
    '@type' => $this
      ->getPluginLabel(),
    'link' => Link::fromTextAndUrl(t('Edit'), Url::fromRoute('<current>'))
      ->toString(),
  ];
  $this->logger
    ->notice("'@title' is a '@type' element, which has been disabled and will not be rendered.", $context);
}