You are here

function dynamic_layouts_requirements in Dynamic Layouts 8

Implements hook_requirements().

File

./dynamic_layouts.install, line 28
Install, update and uninstall functions for the dynamic_layouts module.

Code

function dynamic_layouts_requirements($phase) {
  $requirements = [];
  $moduleHandler = \Drupal::service('module_handler');
  $bootstrap_library_enabled = FALSE;
  if ($moduleHandler
    ->moduleExists('bootstrap_library')) {
    $bootstrap_library_enabled = TRUE;
  }
  if ($phase == 'runtime') {

    /** @var \Drupal\dynamic_layouts\DynamicLayoutSettingsInterface $settings */
    if ($settings = \Drupal::entityTypeManager()
      ->getStorage('dynamic_layout_settings')
      ->load('settings')) {

      // Check if the chosen frontend is Bootstrap.
      if ($settings
        ->getFrontendLibrary() == 'bootstrap' && !$bootstrap_library_enabled) {
        $url = Url::fromUri('https://www.drupal.org/project/bootstrap_library');
        $link = Link::fromTextAndUrl(t('bootstrap_library'), $url)
          ->toString();
        $requirements['dynamic_layouts'] = array(
          'title' => t('Dynamic layouts'),
          'value' => t('Bootstrap library not found'),
          'severity' => REQUIREMENT_WARNING,
          'description' => t('You have selected Bootstrap as your frontend library, to display the layout properly in the frontend: install the @link module & select version 4.x', [
            '@link' => $link,
          ]),
        );
      }
    }
  }
  return $requirements;
}