You are here

gin_toolbar.install in Gin Toolbar 8

Toolbar Installation Checks.

File

gin_toolbar.install
View source
<?php

/**
 * @file
 * Toolbar Installation Checks.
 */
use Drupal\Core\Installer\InstallerKernel;

/**
 * Implements hook_requirements().
 */
function gin_toolbar_requirements($phase) {
  $requirements = [];
  if ($phase !== 'install') {
    return $requirements;
  }

  // We need to check if Gin theme is installed.
  $installed = \Drupal::service('theme_handler')
    ->themeExists('gin');

  // Gin is installed everything's fine.
  if ($installed) {
    return $requirements;
  }
  global $install_state;

  // Check if Drupal should be installed and gin in is in the install profile.
  if (InstallerKernel::installationAttempted() && isset($install_state['profile_info']['themes']) && in_array('gin', $install_state['profile_info']['themes'], TRUE)) {
    return $requirements;
  }

  // Gin is not installed and it's not supposed to be installed.
  $requirements['gin'] = [
    'title' => t('Gin'),
    'description' => t('The Gin Toolbar module works with <a href="https://www.drupal.org/project/gin" target="_blank">Gin</a> theme only'),
    'severity' => REQUIREMENT_ERROR,
  ];
  return $requirements;
}

Functions

Namesort descending Description
gin_toolbar_requirements Implements hook_requirements().