metatag.install in Metatag 8
Same filename and directory in other branches
Requirements and update functions for the Metatag module.
File
metatag.installView source
<?php
/**
* @file
* Requirements and update functions for the Metatag module.
*/
/**
* Implements hook_requirements().
*/
function metatag_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
// Note that no meta tags will be output while the site is in maintenance
// mode.
if (\Drupal::state()
->get('system.maintenance_mode')) {
$requirements['metatag_maintenance_mode'] = [
'severity' => REQUIREMENT_WARNING,
'title' => 'Metatag',
'value' => t('Not enabled while in maintenance mode'),
'description' => t('Please note that while the site is in maintenance mode none of the usual meta tags will be output.'),
];
}
// Recommend the Schema.org Metatag module.
if (!\Drupal::moduleHandler()
->moduleExists('schema_metatag')) {
$requirements['metatag_schema'] = [
'severity' => REQUIREMENT_INFO,
'title' => 'Metatag',
'value' => t('Schema.org Metatag is recommended'),
'description' => t('The <a href="@module">Schema.org Metatag</a> module is highly recommended to add <a href="@jsonld">JSON-LD</a> -formatted <a href="@schema">schema.org</a> compatible data structures to the site.', [
'@module' => 'https://www.drupal.org/project/schema_metatag',
'@jsonld' => 'https://json-ld.org',
'@schema' => 'https://schema.org',
]),
];
}
else {
$requirements['metatag_schema'] = [
'severity' => REQUIREMENT_OK,
'title' => 'Metatag',
'value' => t('Schema.org Metatag is installed'),
'description' => t('The <a href="@module">Schema.org Metatag</a> module is installed.', [
'@module' => 'https://www.drupal.org/project/schema_metatag',
]),
];
}
}
return $requirements;
}
/**
* Implements hook_update_last_removed().
*/
function metatag_update_last_removed() {
return 8106;
}
/**
* Enable the new metatag_open_graph module.
*/
function metatag_update_8107() {
\Drupal::service('module_installer')
->install([
'metatag_open_graph',
]);
return (string) t("The new Metatag: Open Graph module has been enabled.");
}
/**
* Need to clear caches after updating from 8.x-1.12.
*/
function metatag_update_8108() {
return (string) t("The sites's caches will need to be rebuild to ensure Metatag works as intended.");
}
Functions
Name | Description |
---|---|
metatag_requirements | Implements hook_requirements(). |
metatag_update_8107 | Enable the new metatag_open_graph module. |
metatag_update_8108 | Need to clear caches after updating from 8.x-1.12. |
metatag_update_last_removed | Implements hook_update_last_removed(). |