w3c_validator.install in W3C Validator 8
Same filename and directory in other branches
Install, update and uninstall functions for the w3c_validator module.
File
w3c_validator.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the w3c_validator module.
*/
use Drupal\Core\Database\Database;
use Drupal\Core\Utility\UpdateException;
/**
* Implements hook_schema().
*/
function w3c_validator_schema() {
$schema['w3c_validator'] = [
'description' => 'Store already validated URI',
'fields' => [
'wid' => [
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique link ID.',
],
'uri' => [
'type' => 'text',
'not null' => TRUE,
'description' => 'The full qualified link.',
],
'error_count' => [
'description' => 'Number of errors found during validation.',
'type' => 'int',
'unsigned' => TRUE,
'size' => 'small',
'not null' => TRUE,
'default' => 0,
'disp-width' => '5',
],
'errors' => [
'description' => 'Detailled information about validation errors.',
'type' => 'text',
'size' => 'big',
],
'warning_count' => [
'description' => 'Number of warnings found during validation.',
'type' => 'int',
'unsigned' => TRUE,
'size' => 'small',
'not null' => TRUE,
'default' => 0,
'disp-width' => '5',
],
'warnings' => [
'description' => 'Detailled information about warning errors.',
'type' => 'text',
'size' => 'big',
],
'info_count' => [
'description' => 'Number of infos found during validation.',
'type' => 'int',
'unsigned' => TRUE,
'size' => 'small',
'not null' => TRUE,
'default' => 0,
'disp-width' => '5',
],
'infos' => [
'description' => 'Detailled information about infos.',
'type' => 'text',
'size' => 'big',
],
'validity' => [
'description' => 'A flag : TRUE if the validation is valid.',
'type' => 'int',
'default' => 0,
'not null' => TRUE,
],
'need_validation' => [
'description' => 'A flag : TRUE is re-validation is needed.',
'type' => 'int',
'default' => 1,
'not null' => TRUE,
],
'doctype' => [
'description' => 'Doctype of this page.',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => 'unknown',
],
'charset' => [
'description' => 'Charset of this page.',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => 'unknown',
],
],
'primary key' => [
'wid',
],
];
$schema['w3c_access_token'] = [
'fields' => [
'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'token' => [
'type' => 'varchar',
'length' => '32',
'not null' => FALSE,
],
'expiration' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
],
'rand' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
],
'uid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
],
],
'primary key' => [
'id',
],
];
return $schema;
}
/**
* Update W3C Validator storage table to add support for validator messages.
*/
function w3c_validator_update_8001() {
$info_count = [
'description' => 'Number of infos found during validation.',
'type' => 'int',
'unsigned' => TRUE,
'size' => 'small',
'not null' => TRUE,
'default' => 0,
'disp-width' => '5',
];
$infos = [
'description' => 'Detailled information about infos.',
'type' => 'text',
'size' => 'big',
];
try {
$schema = Database::getConnection()
->schema();
$schema
->addField('w3c_validator', 'info_count', $info_count);
$schema
->addField('w3c_validator', 'infos', $infos);
} catch (Exception $e) {
throw new UpdateException('W3C Validation table could not be properly updated.');
}
return 'W3C Validation table has been updated.';
}
Functions
Name | Description |
---|---|
w3c_validator_schema | Implements hook_schema(). |
w3c_validator_update_8001 | Update W3C Validator storage table to add support for validator messages. |