drupalmonitor.install in Drupalmonitor 8
Installer file of drupalmonitor module
File
drupalmonitor.installView source
<?php
/**
* @file
* Installer file of drupalmonitor module
*/
use Drupal\drupalmonitor\Settings;
/**
* Implements hook_schema().
*/
function drupalmonitor_schema() {
$schema['drupalmonitor_log'] = [
'fields' => [
'id' => [
'type' => 'serial',
'length' => 15,
'not null' => TRUE,
],
'q' => [
'type' => 'text',
'not null' => TRUE,
],
'dt' => [
'type' => 'int',
'not null' => TRUE,
],
'memory' => [
'type' => 'int',
'not null' => TRUE,
],
'execution_time' => [
'type' => 'int',
'not null' => TRUE,
],
],
'primary key' => [
'id',
],
];
return $schema;
}
/**
* Implements hook_enable().
*/
function drupalmonitor_install() {
// Generate Hash.
$hash = md5(microtime() . 'drupalmonitorrocks_salt' . time());
$config = \Drupal::service('config.factory')
->getEditable(Settings::CONFIG_NAME);
$config
->set('drupalmonitor_hash', $hash);
$config
->save();
$message = t("You need to create an account on http://www.drupalmonitor.com in order to monitor your website. The sites security hash is @hash. You can configure Drupalmonitor Connector on the @configurl.", [
'@hash' => $hash,
'@configurl' => '/admin/config/system/drupalmonitor',
]);
\Drupal::messenger()
->addMessage($message);
}
/**
* Implements hook_uninstall().
*/
function drupalmonitor_uninstall() {
// Delete Settings.
\Drupal::configFactory()
->getEditable(Settings::CONFIG_NAME)
->delete();
// Uninstall schema.
drupal_uninstall_schema('drupalmonitor');
}
Functions
Name | Description |
---|---|
drupalmonitor_install | Implements hook_enable(). |
drupalmonitor_schema | Implements hook_schema(). |
drupalmonitor_uninstall | Implements hook_uninstall(). |