log.page.inc in Log entity 8
Contains log.page.inc.
Page callback for Log entities.
File
log.page.incView source
<?php
/**
* @file
* Contains log.page.inc.
*
* Page callback for Log entities.
*/
use Drupal\Core\Render\Element;
use Drupal\Core\Link;
use Drupal\Core\Url;
/**
* Prepares variables for Log templates.
*
* Default template: log.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the user information and any
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_log(array &$variables) {
// Fetch Log Entity Object.
$log = $variables['elements']['#log'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
/**
* Prepares variables for a custom entity type creation list templates.
*
* Default template: log-content-add-list.html.twig.
*
* @param array $variables
* An associative array containing:
* - content: An array of log-types.
*
* @see block_content_add_page()
*/
function template_preprocess_log_content_add_list(&$variables) {
$variables['types'] = array();
$query = \Drupal::request()->query
->all();
foreach ($variables['content'] as $type) {
$variables['types'][$type
->id()] = array(
'link' => Link::fromTextAndUrl($type
->label(), new Url('entity.log.add_form', array(
'log_type' => $type
->id(),
), array(
'query' => $query,
))),
'description' => array(
'#markup' => $type
->label(),
),
'title' => $type
->label(),
'localized_options' => array(
'query' => $query,
),
);
}
}
Functions
Name | Description |
---|---|
template_preprocess_log | Prepares variables for Log templates. |
template_preprocess_log_content_add_list | Prepares variables for a custom entity type creation list templates. |