123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- use Drupal\Core\Url;
- use Drupal\Core\Link;
- use Drupal\Core\Render\Markup;
- function reha_preprocess_html(&$variables) {
- $node = \Drupal::routeMatch()->getParameter('node');
- if ($node){
- $variables['attributes']['class'][] = 'node-type-' . $node->bundle();
- $variables['attributes']['class'][] = 'node-id-' . $node->id();
- }
- }
- function reha_preprocess_page(&$variables) {
- }
- function reha_preprocess_node(&$variables) {
- $node = &$variables['node'];
- $variables['attributes']['class'][] = 'node-type-' . $node->gettype();
- }
- function reha_preprocess_block(&$variables) {
- if ($variables['plugin_id'] === "user_login_block") {
- $url = new Url('user.register', [], ['query' => ['destination' => '/node/add/operation']]);
- $link = new Link('proposer une opération', $url);
- $variables['content']['reha'] = array(
- '#theme' => 'item_list',
- '#items' => [
- 'operations' => [
- "add_operation" => $link->toRenderable(),
- "description" => [
- "#markup" => Markup::create("<p>Créer un compte pour charger une opération</p>")
- ]
- ]
- ]
- );
- }
- if ($variables['plugin_id'] === "page_title_block") {
- if (\Drupal::routeMatch()->getRouteName() === 'node.add') {
- $node_type = \Drupal::routeMatch()->getParameter('node_type');
- if ($node_type->id() === 'operation') {
- $variables['content'] = [
- '#type' => 'page_title',
- '#title' => 'Proposer une opération'
- ];
- }
- }
- }
- }
|