twig_tweak_test.module in Twig Tweak 8.2
Same filename and directory in other branches
Primary module hooks for Twig Tweak test module.
File
tests/twig_tweak_test/twig_tweak_test.moduleView source
<?php
/**
* @file
* Primary module hooks for Twig Tweak test module.
*/
use Drupal\Core\Access\AccessResult;
use Drupal\node\NodeInterface;
/**
* Implements hook_page_bottom().
*/
function twig_tweak_test_page_bottom(array &$page_bottom) {
\Drupal::service('messenger')
->addMessage('Hello world!');
$page_bottom['twig_tweak_test']['#theme'] = 'twig_tweak_test';
}
/**
* Implements hook_theme().
*/
function twig_tweak_test_theme() {
return [
'twig_tweak_test' => [
'variables' => [],
],
];
}
/**
* Prepares variables for twig-tweak-test template.
*/
function template_preprocess_twig_tweak_test(&$vars) {
$vars['node'] = Drupal::routeMatch()
->getParameter('node');
}
/**
* Implements hook_node_access().
*
* @see \Drupal\Tests\twig_tweak\Kernel\AccessTest
*/
function twig_tweak_test_node_access(NodeInterface $node) {
if ($node
->getTitle() == 'Entity access test') {
$result = AccessResult::allowed();
$result
->addCacheTags([
'tag_from_' . __FUNCTION__,
]);
$result
->cachePerUser();
$result
->setCacheMaxAge(50);
return $result;
}
}
Functions
Name | Description |
---|---|
template_preprocess_twig_tweak_test | Prepares variables for twig-tweak-test template. |
twig_tweak_test_node_access | Implements hook_node_access(). |
twig_tweak_test_page_bottom | Implements hook_page_bottom(). |
twig_tweak_test_theme | Implements hook_theme(). |