-
Notifications
You must be signed in to change notification settings - Fork 3
/
yoast_seo_preview.module
61 lines (54 loc) · 1.92 KB
/
yoast_seo_preview.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* @file
* Contains yoast_seo related functions.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\yoast_seo_preview\Form\YoastSeoPreviewFormHandler;
/**
* Implements hook_help().
*/
function yoast_seo_preview_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the yoast_seo_preview module.
case 'help.page.yoast_seo_preview':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('SEO Preview') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_entity_type_alter().
*
* Sets the default yoast_seo_preview_form form handler to entity type node.
*
* @see \Drupal\Core\Entity\Annotation\EntityType
*/
function yoast_seo_preview_entity_type_alter(array &$entity_types) {
/* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_types['node']->setHandlerClass('yoast_seo_preview_form', YoastSeoPreviewFormHandler::class);
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function yoast_seo_preview_form_field_storage_config_edit_form_alter(&$form, FormStateInterface $form_state) {
if ($form_state->getFormObject()->getEntity()->getType() === 'yoast_seo_preview') {
// Hide the cardinality field.
$form['cardinality_container']['#access'] = FALSE;
$form['cardinality_container']['#disabled'] = TRUE;
}
}
/**
* Implements hook_library_info_alter().
*/
function yoast_seo_preview_library_info_alter(&$libraries, $extension) {
if ($extension === 'yoast-seo-drupal' && function_exists('libraries_get_path')) {
if ($library_path = libraries_get_path('yoast-seo-drupal')) {
$libraries['yoast-seo-drupal']['js'] = ['/' . $library_path . '/yoast-seo-drupal.min.js' => ['minified' => TRUE]];
$libraries['yoast-seo-drupal']['css']['component'] = ['/' . $library_path . '/yoast-seo-drupal.min.css' => []];
}
}
}