GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — 8.x-4.x-ch-alone ( 1374a9 )
by Brant
14:20 queued 10s
created

one_preprocess_block()   A

Complexity

Conditions 5
Paths 9

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 12
nc 9
nop 1
dl 0
loc 22
rs 9.5555
c 1
b 0
f 0
1
<?php
2
/**
3
 * @file
4
 * Theme and preprocess functions for blocks.
5
 */
6
7
use Drupal\block\Entity\Block;
8
9
/**
10
 * Implements hook_preprocess_block().
11
 */
12
function one_preprocess_block(&$variables) {
13
  // Add the class container if layout builder is not used.
14
  if (\Drupal::request()->attributes->get('node')) {
15
    $nid = \Drupal::request()->attributes->get('node')->id();
16
    $node = \Drupal::entityTypeManager()->getStorage('node')->load($nid);
17
    if (!$node->layout_builder__layout) {
0 ignored issues
show
Bug introduced by
Accessing layout_builder__layout on the interface Drupal\Core\Entity\EntityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
18
      $variables['attributes']['class'][] = 'container';
19
    }
20
  }
21
  else {
22
    $variables['attributes']['class'][] = 'container';
23
  }
24
25
26
  if (isset($variables['elements']['#id'])) {
27
    $region = Block::load($variables['elements']['#id'])->getRegion();
28
    // Pass block region value to content so this can be used
29
    // in hook_theme_suggestions_menu_alter
30
    $variables['content']['#attributes']['region'] = $region;
31
    // Add the class col for all block in the footer.
32
    if ($region == 'footer') {
33
      $variables['attributes']['class'][] = 'col';
34
    }
35
  }
36
}
37
38
39
40