You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<?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) {
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
}
|