You are here

twig_tweak_test.module in Twig Tweak 8

Primary module hooks for Twig Tweak test module.

File

tests/twig_tweak_test/twig_tweak_test.module
View 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) {
  $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

Namesort descending 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().