You are here

function yamlform_requirements in YAML Form 8

Implements hook_requirements().

1 call to yamlform_requirements()
YamlFormElementManagedFilePublicTest::testPublicUpload in src/Tests/YamlFormElementManagedFilePublicTest.php
Test public upload protection.

File

./yamlform.install, line 33
Install, update and uninstall functions for the YAML Form module.

Code

function yamlform_requirements($phase) {
  if ($phase != 'runtime') {
    return [];
  }
  $requirements = [];

  // Check HTML email handling.

  /** @var \Drupal\yamlform\YamlFormEmailProviderInterface $email_provider */
  $email_provider = \Drupal::service('yamlform.email_provider');
  $email_provider
    ->check();
  $module = $email_provider
    ->getModuleName();
  $mail_plugin_id = $email_provider
    ->getMailPluginId();
  $mail_plugin_definition = $email_provider
    ->getMailPluginDefinition();
  if ($module || $mail_plugin_id) {
    $t_args = [
      '@module' => $module,
      '@plugin_id' => $mail_plugin_id,
      '@plugin_label' => $mail_plugin_definition['label'],
      '@plugin_description' => $mail_plugin_definition['description'],
    ];
    $requirements['yamlform_email'] = [
      'title' => t('YAML Form: HTML email support'),
      'value' => $module ? t('Provided by the @module module.', $t_args) : t('Provided by @plugin_id mail plugin.', $t_args),
      'description' => new FormattableMarkup('@plugin_label: @plugin_description', $t_args),
      'severity' => REQUIREMENT_OK,
    ];
  }
  else {
    $requirements['yamlform_email'] = [
      'title' => t('YAML Form: HTML email support'),
      'value' => t('Unable to determine email module and/or provider'),
      'severity' => REQUIREMENT_ERROR,
    ];
  }

  // Check private file upload.
  $scheme_options = ManagedFile::getVisibleStreamWrappers();
  if (isset($scheme_options['private'])) {
    $requirements['yamlform_file_private'] = [
      'title' => t('YAML Form: Private files'),
      'value' => t('Private file system is set.'),
    ];
  }
  else {
    $requirements['yamlform_file_private'] = [
      'title' => t('YAML Form: Private files'),
      'value' => t('Private file system is not set.'),
      'description' => t('This must be changed in <a href="https://www.drupal.org/documentation/modules/file">settings.php</a>. For more information see: <a href="https://www.drupal.org/psa-2016-003">DRUPAL-PSA-2016-003</a>'),
      'severity' => REQUIREMENT_WARNING,
    ];
  }

  // Check third party libraries status.

  /** @var \Drupal\yamlform\YamlFormLibrariesManagerInterface $libraries_manager */
  $libraries_manager = \Drupal::service('yamlform.libraries_manager');
  $requirements += $libraries_manager
    ->requirements();
  return $requirements;
}