You are here

function _bootstrap_layouts_ensure_dependency in Bootstrap Layouts 8.5

Ensures the proper module and services exist.

Return value

bool TRUE if the services exist, FALSE otherwise.

2 calls to _bootstrap_layouts_ensure_dependency()
bootstrap_layouts_update_8501 in ./bootstrap_layouts.install
Uninstall "layout_plugin" is install "layout_discovery".
_bootstrap_layouts_update in ./bootstrap_layouts.install
Runs updates for registered update plugins.

File

./bootstrap_layouts.install, line 14
Install, uninstall and update hooks for the Bootstrap Layouts module.

Code

function _bootstrap_layouts_ensure_dependency() {
  $module_handler = \Drupal::moduleHandler();

  /** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
  $module_installer = \Drupal::service('module_installer');

  // Uninstall "layout_plugin".
  if ($module_handler
    ->moduleExists('layout_plugin')) {
    $module_installer
      ->uninstall([
      'layout_plugin',
    ], FALSE);
  }

  // Install "layout_discovery".
  if (!$module_handler
    ->moduleExists('layout_discovery')) {
    $module_installer
      ->install([
      'layout_discovery',
    ], FALSE);
  }

  // Rebuild the container if the layout managers don't exist.
  if (!\Drupal::hasService('plugin.manager.core.layout') || !\Drupal::hasService('plugin.manager.bootstrap_layouts')) {
    drupal_flush_all_caches();
  }
  return \Drupal::hasService('plugin.manager.core.layout') && \Drupal::hasService('plugin.manager.bootstrap_layouts');
}