blazy.install in Blazy 7
Same filename and directory in other branches
Installation actions for Blazy.
File
blazy.installView source
<?php
/**
* @file
* Installation actions for Blazy.
*/
use Drupal\blazy\BlazyDefault;
/**
* Checks if Blazy can proceed the install.
*/
function _blazy_can_install() {
return function_exists('registry_autoload_boot') || function_exists('psr0_autoloader') || function_exists('xautoload') || function_exists('autoload');
}
/**
* Implements hook_requirements().
*/
function blazy_requirements($phase) {
$requirements = [];
// Ensure translations do not break at install time.
$t = get_t();
// Must also prevent any class from being initiated as .module file is loaded
// even during install phase.
if ($phase == 'install') {
$exists = _blazy_can_install();
$requirements['blazy_autoloader'] = [
'title' => $t('Blazy autoloader'),
'description' => $exists ? '' : $t('The Blazy module requires one of autoloader modules: <a href="@url1">registry_autoload</a>, <a href="@url2">psr0</a>, <a href="@url3">autoload</a>, <a href="@url4">xautoload</a>.', [
'@url1' => 'https://www.drupal.org/project/registry_autoload',
'@url2' => 'https://www.drupal.org/project/psr0',
'@url3' => 'https://www.drupal.org/project/autoload',
'@url4' => 'https://www.drupal.org/project/xautoload',
]),
'severity' => $exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
'value' => $exists ? $t('installed') : $t('not installed'),
];
}
elseif ($phase == 'runtime') {
$exists = function_exists('libraries_get_path') && is_file(libraries_get_path('blazy') . '/blazy.min.js');
$requirements['blazy_library'] = [
'title' => $t('Blazy library'),
'description' => $exists ? '' : $t('The <a href="@url">Blazy library</a> should be installed at <strong>/sites/.../libraries/blazy/blazy.min.js</strong>, or any path supported by libraries.module. Check out file or folder permissions if troubled', [
'@url' => 'https://github.com/dinbror/blazy',
]),
'severity' => $exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
'value' => $exists ? $t('Installed') : $t('Not installed'),
];
}
return $requirements;
}
/**
* Implements hook_install().
*/
function blazy_install() {
if (_blazy_can_install()) {
variable_set('blazy.settings', BlazyDefault::formSettings());
}
}
/**
* Implements hook_uninstall().
*/
function blazy_uninstall() {
variable_del('blazy.settings');
db_delete('filter')
->condition('module', 'blazy')
->condition('name', 'blazy_filter')
->execute();
}
Functions
Name | Description |
---|---|
blazy_install | Implements hook_install(). |
blazy_requirements | Implements hook_requirements(). |
blazy_uninstall | Implements hook_uninstall(). |
_blazy_can_install | Checks if Blazy can proceed the install. |