mobile_number.install in Mobile Number 8
Same filename and directory in other branches
Install, update and uninstall functions for the systementity_configfield module.
File
mobile_number.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the systementity_configfield module.
*/
/**
* Implements hook_schema().
*/
function mobile_number_schema() {
$schema['mobile_number_verification'] = [
'description' => 'A table for storing verification codes for mobile numbers.',
'fields' => [
'token' => [
'description' => 'Verification token.',
'type' => 'varchar',
'length' => 43,
'not null' => TRUE,
],
'timestamp' => [
'description' => 'The time when the verification token was created.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'verification_code' => [
'description' => 'Hash of the code sent to the user.',
'type' => 'varchar',
'length' => 40,
'not null' => TRUE,
],
],
'indexes' => [
'token_created' => [
'timestamp',
],
],
'primary key' => [
'token',
],
];
return $schema;
}
/**
* Implements hook_install().
*/
function mobile_number_install() {
\Drupal::configFactory()
->getEditable('mobile_number.settings')
->set('verification_secret', \Drupal::csrfToken()
->get('mobile number secret' . rand(0, 999999999)))
->save();
}
/**
* Implements hook_requirements().
*/
function mobile_number_requirements($phase) {
$requirements = [];
$requirements['mobile_number_library'] = [
'title' => t('Libphonenumber-for-php library'),
];
if (class_exists('\\libphonenumber\\PhoneNumber')) {
$requirements['mobile_number_library']['value'] = t('Installed');
$requirements['mobile_number_library']['severity'] = REQUIREMENT_OK;
}
else {
$requirements['mobile_number_library']['value'] = t('Not Installed');
$requirements['mobile_number_library']['severity'] = REQUIREMENT_ERROR;
$requirements['mobile_number_library']['description'] = t('Please install the libphonenumber-for-php library via Composer.');
}
return $requirements;
}
Functions
Name | Description |
---|---|
mobile_number_install | Implements hook_install(). |
mobile_number_requirements | Implements hook_requirements(). |
mobile_number_schema | Implements hook_schema(). |