You are here

public function YamlFormManagedFileBase::displayDisabledWarning in YAML Form 8

Display element disabled warning.

Parameters

array $element: An element.

Overrides YamlFormElementBase::displayDisabledWarning

1 call to YamlFormManagedFileBase::displayDisabledWarning()
YamlFormManagedFileBase::prepare in src/Plugin/YamlFormElement/YamlFormManagedFileBase.php
Prepare an element to be rendered within a form.

File

src/Plugin/YamlFormElement/YamlFormManagedFileBase.php, line 76

Class

YamlFormManagedFileBase
Provides a base class form 'managed_file' elements.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function displayDisabledWarning(array $element) {

  // Display standard disabled element warning.
  if (!parent::isEnabled()) {
    parent::displayDisabledWarning($element);
  }
  else {

    // Display 'managed_file' stream wrappers warning.
    $scheme_options = self::getVisibleStreamWrappers();
    $uri_scheme = $this
      ->getUriScheme($element);
    if (!isset($scheme_options[$uri_scheme]) && $this->currentUser
      ->hasPermission('administer yamlform')) {
      drupal_set_message($this
        ->t('The \'Managed file\' element is unavailable because a <a href="https://www.drupal.org/documentation/modules/file">private files directory</a> has not been configured and public file uploads have not been enabled. For more information see: <a href="https://www.drupal.org/psa-2016-003">DRUPAL-PSA-2016-003</a>'), 'warning');
      $context = [
        'link' => Link::fromTextAndUrl($this
          ->t('Edit'), \Drupal\Core\Url::fromRoute('<current>'))
          ->toString(),
      ];
      $this->logger
        ->notice("The 'Managed file' element is unavailable because no stream wrappers are available", $context);
    }
  }
}