-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhoward_remove_promoted.module
More file actions
46 lines (41 loc) · 1.36 KB
/
howard_remove_promoted.module
File metadata and controls
46 lines (41 loc) · 1.36 KB
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
<?php
/**
* @file
* Implements various hooks and functions to run the Remove Promoted.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_form_alter().
*
*/
function howard_remove_promoted_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
{
if ($form_id == 'node_hc_page_edit_form' || $form_id == 'node_hc_page_form') {
unset($form['promote']);
unset($form['sticky']);
}
}
/**
* Implements hook_help().
*
* @inheritdoc
*/
function howard_remove_promoted_help($route_name, RouteMatchInterface $route_match)
{
switch ($route_name) {
case 'help.page.howard_remove_promotes':
$text = file_get_contents(dirname(__FILE__) . "/README.md");
if (!\Drupal::moduleHandler()->moduleExists('markdown')) {
return '<pre>' . $text . '</pre>';
} else {
// Use the Markdown filter to render the README.
$filter_manager = \Drupal::service('plugin.manager.filter');
$settings = \Drupal::configFactory()->get('markdown.settings')->getRawData();
$config = ['settings' => $settings];
$filter = $filter_manager->createInstance('markdown', $config);
return $filter->process($text, 'en');
}
}
return NULL;
}