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 ( 48ddc9...debf9b )
by Kevin
04:55
created

one_preprocess_block()   A

Complexity

Conditions 5
Paths 9

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 11
c 1
b 0
f 0
nc 9
nop 1
dl 0
loc 18
rs 9.6111
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
  // Add the class col for all block in the footer.
26
  if (isset($variables['elements']['#id'])) {
27
    $region = Block::load($variables['elements']['#id'])->getRegion();
28
    if ($region == 'footer') {
29
      $variables['attributes']['class'][] = 'col';
30
    }
31
  }
32
}
33