41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Callbacks for adding, editing, and deleting content and managing revisions.
|
|
*
|
|
* Also includes validation, submission and other helper functions.
|
|
*
|
|
* @see node_menu()
|
|
*/
|
|
|
|
use Drupal\Component\Utility\Xss;
|
|
use Drupal\Core\Url;
|
|
use Drupal\Core\Form\FormStateInterface;
|
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
use Drupal\node\NodeInterface;
|
|
|
|
/**
|
|
* Prepares variables for list of available node type templates.
|
|
*
|
|
* Default template: node-add-list.html.twig.
|
|
*
|
|
* @param array $variables
|
|
* An associative array containing:
|
|
* - content: An array of content types.
|
|
*
|
|
* @see node_add_page()
|
|
*/
|
|
function template_preprocess_node_add_list(&$variables) {
|
|
$variables['types'] = array();
|
|
if (!empty($variables['content'])) {
|
|
foreach ($variables['content'] as $type) {
|
|
$variables['types'][$type->id()] = array(
|
|
'type' => $type->id(),
|
|
'add_link' => \Drupal::l($type->label(), new Url('node.add', array('node_type' => $type->id()))),
|
|
'description' => Xss::filterAdmin($type->getDescription()),
|
|
);
|
|
}
|
|
}
|
|
}
|