You are here

colorbox.install in Colorbox 8

Same filename and directory in other branches
  1. 6 colorbox.install
  2. 7.2 colorbox.install
  3. 7 colorbox.install

Install, update and uninstall functions for the colorbox module.

File

colorbox.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the colorbox module.
 */

/**
 * Implements hook_install().
 */
function colorbox_install() {
  \Drupal::messenger()
    ->addMessage(t('Thanks for installing Colorbox'));
}

/**
 * Implements hook_requirements().
 */
function colorbox_requirements($phase) {
  if ($phase != 'runtime') {
    return [];
  }
  $library = \Drupal::service('library.discovery')
    ->getLibraryByName('colorbox', 'colorbox');
  $library_exists = file_exists(DRUPAL_ROOT . '/' . $library['js'][0]['data']);
  return [
    'colorbox_library_downloaded' => [
      'title' => t('Colorbox library'),
      'value' => $library_exists ? t('Installed') : t('Not installed'),
      'description' => $library_exists ? '' : t('The Colorbox library needs to be <a href="@url">downloaded</a> and extracted into the /libraries/colorbox folder in your Drupal installation directory.', [
        '@url' => 'https://github.com/jackmoore/colorbox/archive/master.zip',
      ]),
      'severity' => $library_exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    ],
  ];
}

Functions