varbase_seo.install in Varbase SEO 8.4
Same filename and directory in other branches
Install, update and uninstall functions for the Varbase SEO module.
File
varbase_seo.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the Varbase SEO module.
*/
use Symfony\Component\Yaml\Yaml;
/**
* Implements hook_install().
*
* @see system_install()
*/
function varbase_seo_install() {
// Enable Google Analytics
if (!\Drupal::moduleHandler()
->moduleExists('google_analytics')) {
\Drupal::service('module_installer')
->install([
'google_analytics',
], FALSE);
}
$module_path = Drupal::service('module_handler')
->getModule('varbase_seo')
->getPath();
$optional_configs = [
'google_analytics.settings',
];
foreach ($optional_configs as $optional_config) {
$config_path = $module_path . '/config/optional/' . $optional_config . '.yml';
$config_content = file_get_contents($config_path);
$config_data = (array) Yaml::parse($config_content);
$config_factory = \Drupal::configFactory()
->getEditable($optional_config);
$config_factory
->setData($config_data)
->save(TRUE);
}
}
/**
* Enable Metatag: Facebook module.
*/
function varbase_seo_update_8001() {
if (!\Drupal::moduleHandler()
->moduleExists('metatag_facebook')) {
\Drupal::service('module_installer')
->install([
'metatag_facebook',
], FALSE);
}
}
/**
* Enable Metatag: Google Plus module.
*/
function varbase_seo_update_8002() {
if (!\Drupal::moduleHandler()
->moduleExists('metatag_google_plus')) {
\Drupal::service('module_installer')
->install([
'metatag_google_plus',
], FALSE);
}
}
/**
* Enable Metatag: hreflang module.
*/
function varbase_seo_update_8003() {
if (!\Drupal::moduleHandler()
->moduleExists('metatag_hreflang')) {
\Drupal::service('module_installer')
->install([
'metatag_hreflang',
], FALSE);
}
}
/**
* Enable Metatag: Mobile & UI Adjustments module.
*/
function varbase_seo_update_8004() {
if (!\Drupal::moduleHandler()
->moduleExists('metatag_mobile')) {
\Drupal::service('module_installer')
->install([
'metatag_mobile',
], FALSE);
}
}
/**
* Enable Metatag: Open Graph module.
*/
function varbase_seo_update_8005() {
if (!\Drupal::moduleHandler()
->moduleExists('metatag_open_graph')) {
\Drupal::service('module_installer')
->install([
'metatag_open_graph',
], FALSE);
}
}
/**
* Enable Metatag: Twitter Cards module.
*/
function varbase_seo_update_8006() {
if (!\Drupal::moduleHandler()
->moduleExists('metatag_twitter_cards')) {
\Drupal::service('module_installer')
->install([
'metatag_twitter_cards',
], FALSE);
}
}
/**
* Enable Metatag: Verification module.
*/
function varbase_seo_update_8007() {
if (!\Drupal::moduleHandler()
->moduleExists('metatag_verification')) {
\Drupal::service('module_installer')
->install([
'metatag_verification',
], FALSE);
}
}
/**
* Enable Real-time SEO for Drupal module.
*/
function varbase_seo_update_8008() {
if (!\Drupal::moduleHandler()
->moduleExists('yoast_seo')) {
\Drupal::service('module_installer')
->install([
'yoast_seo',
], FALSE);
}
}
/**
* Enable Simple XML Sitemap module.
*/
function varbase_seo_update_8009() {
if (!\Drupal::moduleHandler()
->moduleExists('simple_sitemap')) {
\Drupal::service('module_installer')
->install([
'simple_sitemap',
], FALSE);
}
}
/**
* Enable Google Analytics module.
*/
function varbase_seo_update_8010() {
if (!\Drupal::moduleHandler()
->moduleExists('google_analytics')) {
\Drupal::service('module_installer')
->install([
'google_analytics',
], FALSE);
}
}
/**
* Enable Redirect 404 module.
*/
function varbase_seo_update_8011() {
if (!\Drupal::moduleHandler()
->moduleExists('redirect_404')) {
\Drupal::service('module_installer')
->install([
'redirect_404',
], FALSE);
}
}
/**
* Enable Schema Metatag module.
*/
function varbase_seo_update_8012() {
if (!\Drupal::moduleHandler()
->moduleExists('schema_metatag')) {
\Drupal::service('module_installer')
->install([
'schema_metatag',
], FALSE);
}
}
/**
* Enable Schema Web Site module.
*/
function varbase_seo_update_8013() {
if (!\Drupal::moduleHandler()
->moduleExists('schema_web_site')) {
\Drupal::service('module_installer')
->install([
'schema_web_site',
], FALSE);
}
}
/**
* Enable Schema Web Page module.
*/
function varbase_seo_update_8014() {
if (!\Drupal::moduleHandler()
->moduleExists('schema_web_page')) {
\Drupal::service('module_installer')
->install([
'schema_web_page',
], FALSE);
}
}
/**
* Enable Schema Article module.
*/
function varbase_seo_update_8015() {
if (!\Drupal::moduleHandler()
->moduleExists('schema_article')) {
\Drupal::service('module_installer')
->install([
'schema_article',
], FALSE);
}
}
/**
* Enable Schema Item List module.
*/
function varbase_seo_update_8016() {
if (!\Drupal::moduleHandler()
->moduleExists('schema_item_list')) {
\Drupal::service('module_installer')
->install([
'schema_item_list',
], FALSE);
}
}
Functions
Name | Description |
---|---|
varbase_seo_install | Implements hook_install(). |
varbase_seo_update_8001 | Enable Metatag: Facebook module. |
varbase_seo_update_8002 | Enable Metatag: Google Plus module. |
varbase_seo_update_8003 | Enable Metatag: hreflang module. |
varbase_seo_update_8004 | Enable Metatag: Mobile & UI Adjustments module. |
varbase_seo_update_8005 | Enable Metatag: Open Graph module. |
varbase_seo_update_8006 | Enable Metatag: Twitter Cards module. |
varbase_seo_update_8007 | Enable Metatag: Verification module. |
varbase_seo_update_8008 | Enable Real-time SEO for Drupal module. |
varbase_seo_update_8009 | Enable Simple XML Sitemap module. |
varbase_seo_update_8010 | Enable Google Analytics module. |
varbase_seo_update_8011 | Enable Redirect 404 module. |
varbase_seo_update_8012 | Enable Schema Metatag module. |
varbase_seo_update_8013 | Enable Schema Web Site module. |
varbase_seo_update_8014 | Enable Schema Web Page module. |
varbase_seo_update_8015 | Enable Schema Article module. |
varbase_seo_update_8016 | Enable Schema Item List module. |