accessibility-8.x-1.x-dev/accessibility.install
accessibility.install
<?php
use Drupal\Core\Link;
use Drupal\Core\Url;
const ACCESSIBILITY_QUAIL_VERSION = '2.0.3';
/**
* Implements hook_requirements().
*/
function accessibility_requirements($phase) {
if (!\Drupal::moduleHandler()->moduleExists('libraries')) {
return [];
}
$requirements = ['quail_installed' => ['title' => t('QUAIL library installed')]];
$library_path = libraries_get_path('quail');
if ($library_path && file_exists($library_path . '/quail.json')) {
$version = json_decode(file_get_contents($library_path . '/quail.json'));
if (version_compare(ACCESSIBILITY_QUAIL_VERSION, $version->version) < 1) {
$requirements['quail_installed']['value'] = t('QUAIL version @version installed',
['@version' => $version->version]);
$requirements['quail_installed']['severity'] = REQUIREMENT_OK;
}
else {
$requirements['quail_installed']['value'] = t('QUAIL should be at least version 2.0.3, installed version is @version',
['@version' => $version->version]);
$requirements['quail_installed']['severity'] = REQUIREMENT_ERROR;
$requirements['quail_installed']['description'] = t('You must download the !link and install it in your libraries folder, and make sure the folder is re-named to "quail" without a version number.',
[
'!link' => Link::fromTextAndUrl('QUAIL jQuery library',
Url::fromUri('https://github.com/kevee/quail/releases')),
]
);
}
}
else {
$requirements['quail_installed']['value'] = t('QUAIL not installed');
$requirements['quail_installed']['severity'] = REQUIREMENT_ERROR;
$requirements['quail_installed']['description'] = t('You must download the @link version @version and install it in your libraries folder, and make sure the folder is re-named to "quail" without a version number.',
[
'@version' => ACCESSIBILITY_QUAIL_VERSION,
'@link' => Link::fromTextAndUrl('QUAIL jQuery library',
Url::fromUri('https://github.com/kevee/quail/releases')),
]
);
}
return $requirements;
}
/**
* Implements hook_schema().
*/
function accessibility_schema() {
$schema = [];
$schema['accessibility_test'] = [
'description' => 'Accessibility tests.',
'fields' => [
'test_id' => [
'description' => 'Primary Key: Identifier for an accessibility test.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'uuid' => [
'description' => 'Unique Key: Universally unique identifier for this entity.',
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
],
'langcode' => [
'description' => 'The language of the test.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
],
'name' => [
'description' => 'The name of the test - a human-readable identifier.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'quail_name' => [
'description' => 'The name of the related QUAIL test label.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'severity' => [
'description' => 'The severity of the test.',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => 'suggestion',
],
'status' => [
'description' => 'Whether the test is active or not.',
'type' => 'int',
'length' => 1,
'not null' => TRUE,
'default' => 1,
],
'created' => [
'description' => 'The Unix timestamp when the test was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
],
'changed' => [
'description' => 'The Unix timestamp when the test was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
],
'data' => [
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of additional data.',
],
],
'primary key' => ['test_id'],
];
return $schema;
}
