build_hooks.module in Build Hooks 8
Same filename and directory in other branches
Contains build_hooks.module.
File
build_hooks.moduleView source
<?php
/**
* @file
* Contains build_hooks.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
/**
* Implements hook_help().
*/
function build_hooks_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the build_hooks module.
case 'help.page.build_hooks':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('build hooks') . '</p>';
return $output;
default:
}
}
/**
* Implement hook_cron
*/
function build_hooks_cron() {
getTriggerService()
->executeCron();
}
/**
* Implements hook_entity_update().
*/
function build_hooks_entity_update(EntityInterface $entity) {
getTriggerService()
->executeNode($entity
->getType());
}
/**
* Implements hook_toolbar().
*/
function build_hooks_toolbar() {
if (getTriggerService()
->showMenu()) {
$items['build_hooks'] = [
'#cache' => [
'contexts' => [
'user.permissions',
],
],
'#weight' => 999,
'#type' => 'toolbar_item',
'tab' => [
'#type' => 'link',
'#title' => t('Execute Build Hook'),
'#url' => Url::fromRoute('build_hooks.trigger_controller_execute'),
],
];
return $items;
}
}
function getTriggerService() {
return \Drupal::service('build_hooks.trigger');
}
Functions
Name | Description |
---|---|
build_hooks_cron | Implement hook_cron |
build_hooks_entity_update | Implements hook_entity_update(). |
build_hooks_help | Implements hook_help(). |
build_hooks_toolbar | Implements hook_toolbar(). |
getTriggerService |