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-cleanup ( 9d0b42...49ea55 )
by Brant
04:23
created

df_tools_blocks_migration_plugins_alter()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/**
4
 * @file
5
 * Contains df_tools_blocks.module.
6
 */
7
8
use Drupal\block_content\Entity\BlockContent;
9
use Drupal\block_content\Entity\BlockContentType;
10
use Drupal\Component\Utility\Html;
11
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
12
use Drupal\Core\Entity\EntityInterface;
13
use Drupal\Core\Entity\FieldableEntityInterface;
14
use Drupal\Core\Form\FormStateInterface;
15
use Drupal\Core\Render\Element;
16
use Drupal\Core\StringTranslation\TranslatableMarkup;
17
use Drupal\field\Entity\FieldConfig;
18
19
/**
20
 * Implements hook_modules_installed().
21
 */
22
function df_tools_blocks_modules_installed(array $modules) {
23
  // Don't do anything during config sync.
24
  if (\Drupal::isConfigSyncing()) {
25
    return;
26
  }
27
28
  // Add support for Acquia DAM Asset media entities to the Media field if the
29
  // df_tools_media_acquiadam module is installed.
30
  if (in_array('df_tools_media_acquiadam', $modules)) {
31
    // Retrieve the block's 'media' field.
32
    $instance = FieldConfig::loadByName('block_content', 'media', 'field_media');
33
34
    // Add 'acquia_dam_asset' to the list of allowed target bundles.
35
    $settings = $instance->getSetting('handler_settings');
36
    $settings['target_bundles'][] = 'acquia_dam_asset';
37
    $instance->setSetting('handler_settings', $settings);
38
    $instance->save();
39
  }
40
}
41
42
/**
43
 * Implements hook_ENTITY_TYPE_view_alter().
44
 */
45
function df_tools_blocks_block_content_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
46
  if ($entity->bundle() === 'basic') {
47
    $wrapper = [
48
      '#prefix' => '<div class="full-width-inner">',
49
      '#suffix' => '</div>',
50
      '#type' => 'container',
51
      '#weight' => -1,
52
      '#attributes' => [
53
        'class' => ['basic-block-fields'],
54
      ],
55
    ];
56
    $build['wrapper'] = $wrapper;
57
    $build['#prefix'] = '<div class="basic-block">';
58
    $build['#suffix'] = '</div>';
59
  }
60
61
  if ($entity->bundle() === 'hero') {
62
63
    $hero_alignment = $entity->get('field_hero_alignment')->getString();
0 ignored issues
show
Bug introduced by
The method get() does not exist on Drupal\Core\Entity\EntityInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Drupal\Core\Entity\Entity or Drupal\Tests\Core\Entity...rageTestEntityInterface or Drupal\Core\Entity\Entit...uginCollectionInterface or Drupal\Tests\Core\Entity\SimpleTestEntity or Drupal\Tests\content_mod...n\Unit\SimpleTestEntity or Drupal\Tests\Core\Entity\RevisionableEntity. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
    $hero_alignment = $entity->/** @scrutinizer ignore-call */ get('field_hero_alignment')->getString();
Loading history...
64
    if (preg_match('/^[a-z_]+$/i', $hero_alignment)) {
65
      switch ($hero_alignment) {
66
        case 'center':
67
          $hero_alignment = 'justify-content-center';
68
          break;
69
        case 'right':
70
          $hero_alignment = 'justify-content-end';
71
          break;
72
        default:
73
          $hero_alignment = 'justify-content-start';
74
          break;
75
      }
76
    }
77
78
    $wrapper = [
79
      '#prefix' => '<div class="container"><div class="row ' . $hero_alignment . '">',
80
      '#suffix' => '</div></div>',
81
      '#type' => 'container',
82
      '#weight' => -1,
83
      '#attributes' => [
84
        'class' => ['hero-block-fields', 'col-md-7', 'col-lg-5'],
85
      ],
86
      '#children' => [],
87
    ];
88
    foreach (Element::getVisibleChildren($build) as $field_name) {
89
      if ($field_name === 'field_icon' && isset($build[$field_name]['#object'])) {
90
        $icon = $build[$field_name]['#object']->field_icon->getString();
91
        if (!empty($icon)) {
92
          $wrapper['#children'][$field_name] = [
93
            '#markup' => '<i class="fa ' . $icon . ' hero-icon"></i>',
94
            '#allowed_tags' => ['i'],
95
          ];
96
        }
97
        unset($build[$field_name]);
98
      }
99
      elseif ($field_name !== 'field_hero_background') {
100
        $wrapper['#children'][$field_name] = $build[$field_name];
101
        unset($build[$field_name]);
102
      }
103
    }
104
    // Attach styles.
105
    $alignment = $entity->get('field_hero_alignment')->getString();
106
    if (preg_match('/^[a-z_]+$/i', $alignment)) {
107
      $wrapper['#attributes']['class'][] = Html::cleanCssIdentifier('hero-block-align-' . $alignment);
108
    }
109
    $color_regex = '/^#[0-9a-f]{6}$/i';
110
    $text_color = $entity->get('field_text_color')->getString();
111
    if (preg_match($color_regex, $text_color)) {
112
      $wrapper['#children']['field_first_line']['#attributes']['style'] = 'color: ' . $text_color;
113
      $wrapper['#children']['field_second_line']['#attributes']['style'] = 'color: ' . $text_color;
114
    }
115
    $gradient_color = $entity->get('field_gradient_color')->getString();
116
    if (preg_match($color_regex, $gradient_color)) {
117
      switch ($alignment) {
118
        case 'left':
119
          $direction = 'to right';
120
          break;
121
122
        case 'right':
123
          $direction = 'to left';
124
          break;
125
126
        default:
127
          $direction = 'to bottom';
128
          break;
129
      }
130
      $build['field_hero_background']['#attributes']['style'] = "background-image: linear-gradient($direction, $gradient_color, transparent)";
131
    }
132
    $callout_color = $entity->get('field_callout_color')->getString();
133
    if (preg_match($color_regex, $callout_color)) {
134
      $style = 'background-color: ' . $callout_color . ';';
135
      $hex = trim($callout_color, '#');
136
      $r = hexdec(substr($hex, 0, 2));
137
      $g = hexdec(substr($hex, 2, 2));
138
      $b = hexdec(substr($hex, 4, 2));
139
      if ($r + $g + $b > 382) {
140
        $wrapper['#children']['field_hero_link'][0]['#attributes']['class'][] = 'hero-link-light-bg';
141
        $style .= 'border-color:black;color:black;';
142
      }
143
      else {
144
        $wrapper['#children']['field_hero_link'][0]['#attributes']['class'][] = 'hero-link-dark-bg';
145
        $style .= 'border-color:white;color:white;';
146
      }
147
      $wrapper['#children']['field_hero_link'][0]['#attributes']['style'] = $style;
148
    }
149
    $wrapper['#attached']['library'][] = 'df_tools_blocks/hero';
150
    $build['wrapper'] = $wrapper;
151
    $build['#prefix'] = '<div class="hero-block">';
152
    $build['#suffix'] = '</div>';
153
  }
154
  if ($entity->bundle() === 'video_hero') {
155
    $wrapper = [
156
      '#type' => 'container',
157
      '#weight' => -1,
158
      '#attributes' => [
159
        'class' => ['video-hero-block-fields'],
160
      ],
161
      '#children' => [],
162
    ];
163
    foreach (Element::getVisibleChildren($build) as $field_name) {
164
      if ($field_name === 'field_hero_link') {
165
        $build[$field_name]['#attributes']['class'][] = 'button';
166
      }
167
      if ($field_name !== 'field_media') {
168
        $wrapper['#children'][$field_name] = $build[$field_name];
169
        unset($build[$field_name]);
170
      }
171
    }
172
    $build['wrapper'] = $wrapper;
173
    $build['#attributes']['class'][] = 'video-hero-block';
174
    $build['#attributes']['class'][] = 'full-width-row';
175
    $build['#attached']['library'][] = 'df_tools_blocks/video_hero';
176
  }
177
}
178
179
/**
180
 * Implements hook_theme_suggestions_HOOK_alter().
181
 */
182
function df_tools_blocks_theme_suggestions_block_alter(array &$suggestions, array $variables) {
183
  // Add block--block-content--bundle.html.twig suggestions.
184
  if (isset($variables['elements']['content']) && isset($variables['elements']['content']['#block_content'])) {
185
    /** @var \Drupal\block_content\Entity\BlockContent $entity */
186
    $entity = $variables['elements']['content']['#block_content'];
187
    $suggestions[] = 'block__block_content__' . $entity->bundle();
188
  }
189
}
190
191
/**
192
 * Implements hook_form_alter().
193
 */
194
function df_tools_blocks_form_alter(&$form, FormStateInterface $form_state, $form_id) {
195
  if (preg_match('/^block_content.*panels_ipe_form$/', $form_id)) {
196
    // Wrap the revision information and any other vertical tabs in a fieldset.
197
    // This breaks vertical tab styling, but we don't want this open most of
198
    // the time anyway.
199
    $form['advanced'] = [
200
      '#type' => 'details',
201
      '#title' => t('Advanced'),
202
      '#collapsed' => TRUE,
203
      '#attributes' => ['class' => ['fieldset']],
204
      '#weight' => 100,
205
      0 => $form['advanced'],
206
    ];
207
208
    // Hide the Block description description and remove any mention of "Block".
209
    $form['info']['widget'][0]['value']['#title'] = t('Description');
210
    $form['info']['widget'][0]['value']['#description'] = [];
211
  }
212
213
  if (preg_match('/^block_content_\X*_edit_form$/', $form_id)) {
214
    // Add a 'copy' button to all custom blocks edit forms.
215
    $form['actions']['copy'] = [
216
      '#type' => 'submit',
217
      '#value' => t('Copy'),
218
      '#submit' => ['df_tools_blocks_block_content_replicate'],
219
      '#weight' => 9,
220
    ];
221
  }
222
}
223
224
/**
225
 * Implements hook_form_FORM_ID_alter().
226
 */
227
function df_tools_blocks_form_panels_ipe_block_plugin_form_alter(&$form, FormStateInterface $form_state, $form_id) {
228
  // Modify the block placement form.
229
  if (isset($form['flipper']['front']['settings']['admin_label'])) {
230
    $form['flipper']['front']['settings']['admin_label']['#weight'] = -2;
231
  }
232
233
  if (isset($form['flipper']['front']['settings']['label_display'])) {
234
    if (empty($form['uuid']['#value'])) {
235
      $form['flipper']['front']['settings']['label_display']['#default_value'] = FALSE;
236
    }
237
    $form['flipper']['front']['settings']['label_display']['#weight'] = -1;
238
  }
239
240
  if (isset($form['flipper']['front']['settings']['label'])) {
241
    $form['flipper']['front']['settings']['label']['#weight'] = 0;
242
    $form['flipper']['front']['settings']['label']['#states'] = [
243
      'visible' => [
244
        ':input[name="settings[label_display]"]' => ['checked' => TRUE],
245
      ],
246
    ];
247
  }
248
249
  // Add special logic for the Entity Browser block plugins.
250
  if (isset($form['plugin_id'])) {
251
    if ($form['plugin_id']['#value'] === 'content_embed') {
252
      // Only auto-open the Content Embed block if it is empty.
253
      if (empty(Element::getVisibleChildren($form['flipper']['front']['settings']['selection']['table'])) && !$form_state->isProcessingInput()) {
254
        $form['#attached']['library'][] = 'df_tools_blocks/auto_open';
255
        $form['#attributes']['data-df-tools-blocks-auto-open'] = 'settings_selection_nids_entity_browser';
256
      }
257
258
      // Modify the Content Embed form to guide users to valid View Modes.
259
      if (empty($form['flipper']['front']['settings']['view_mode']['#default_value'])) {
260
        $form['flipper']['front']['settings']['view_mode']['#default_value'] = 'featured';
261
      }
262
      $excluded_modes = [
263
        'basic_info',
264
        'content_browser',
265
        'rss',
266
        'search_index',
267
        'search_result',
268
        'token',
269
        'full',
270
        'df',
271
      ];
272
      foreach ($excluded_modes as $view_mode) {
273
        if (isset($form['flipper']['front']['settings']['view_mode']['#options'][$view_mode])) {
274
          unset($form['flipper']['front']['settings']['view_mode']['#options'][$view_mode]);
275
        }
276
      }
277
    }
278
    elseif ($form['plugin_id']['#value'] === 'media_embed') {
279
      if (empty(Element::getVisibleChildren($form['flipper']['front']['settings']['selection']['table'])) && !$form_state->isProcessingInput()) {
280
        $form['#attached']['library'][] = 'df_tools_blocks/auto_open';
281
        $form['#attributes']['data-df-tools-blocks-auto-open'] = 'settings_selection_mids_entity_browser';
282
      }
283
      $excluded_modes = [
284
        'media_browser',
285
        'product_slideshow_thumbnail',
286
        'hero_thin',
287
        'hero_product',
288
        'embedded',
289
        'token',
290
      ];
291
      foreach ($excluded_modes as $view_mode) {
292
        if (isset($form['flipper']['front']['settings']['view_mode']['#options'][$view_mode])) {
293
          unset($form['flipper']['front']['settings']['view_mode']['#options'][$view_mode]);
294
        }
295
      }
296
    }
297
  }
298
}
299
300
/**
301
 * Implements hook_form_FORM_ID_alter().
302
 */
303
function df_tools_blocks_form_block_content_hero_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {
304
  df_tools_blocks_form_block_content_hero_panels_ipe_form_alter($form, $form_state, $form_id);
305
}
306
307
/**
308
 * Implements hook_form_FORM_ID_alter().
309
 */
310
function df_tools_blocks_form_block_content_hero_panels_ipe_form_alter(&$form, FormStateInterface $form_state, $form_id) {
311
  // Move the hero image out of the details element and set a better label.
312
  $form['field_hero_background']['widget']['#type'] = 'container';
313
  $form['field_hero_background']['widget']['entity_browser']['#process'][] = '_df_tools_blocks_hero_browser_button';
314
  // Remove the link fieldset and put the URI and title side-by-side.
315
  $form['field_hero_link']['widget'][0]['#type'] = 'container';
316
  $form['field_hero_link']['widget'][0]['#attributes']['class'][] = 'row';
317
  unset($form['field_hero_link']['widget'][0]['uri']['#description']);
318
  $form['field_hero_link']['widget'][0]['uri']['#title'] = t('Callout link');
319
  $form['field_hero_link']['widget'][0]['title']['#title'] = t('Callout text');
320
  $form['field_hero_link']['widget'][0]['uri']['#prefix'] = '<div class="large-6 columns">';
321
  $form['field_hero_link']['widget'][0]['uri']['#suffix'] = '</div>';
322
  $form['field_hero_link']['widget'][0]['title']['#prefix'] = '<div class="large-6 columns">';
323
  $form['field_hero_link']['widget'][0]['title']['#suffix'] = '</div>';
324
  // Group complex form elements into the advanced section.
325
  $form['field_icon']['#attributes']['class'][] = 'visually-hidden';
326
  $form['field_nested_block']['#attributes']['class'][] = 'visually-hidden';
327
  $style_fields = [
328
    'field_text_color',
329
    'field_gradient_color',
330
    'field_callout_color',
331
  ];
332
  $form['style_fields'] = [
333
    '#type' => 'container',
334
    '#attributes' => ['class' => ['row']],
335
  ];
336
  foreach ($style_fields as $field) {
337
    if (strpos($field, 'color') !== FALSE) {
338
      $form[$field]['widget'][0]['value']['#type'] = 'color';
339
    }
340
    $form[$field]['#attributes']['class'][] = 'large-4 columns';
341
    $form['style_fields'][] = $form[$field];
342
    $form['style_fields']['#weight'] = $form[$field]['#weight'];
343
    unset($form[$field]);
344
  }
345
}
346
347
/**
348
 * Does nit-picky changes on the Hero image entity browser.
349
 *
350
 * @param array $element
351
 *   The element render array.
352
 *
353
 * @return array
354
 *   The possibly modified form render array.
355
 */
356
function _df_tools_blocks_hero_browser_button(array $element) {
357
  $element['entity_browser']['open_modal']['#value'] = t('Select background');
358
  if (isset($element['entity_browser']['open_modal']['#ajax'])) {
359
    /** @var \Drupal\entity_browser\DisplayInterface $display */
360
    $display = $element['entity_browser']['open_modal']['#ajax']['callback'][0];
361
    $configuration = $display->getConfiguration();
362
    $configuration['link_text'] = t('Background media');
363
    $display->setConfiguration($configuration);
364
  }
365
  return $element;
366
}
367
368
/**
369
 * Callback to re-sort blocks into categories.
370
 *
371
 * @param array &$block_info
372
 *   An array of block plugin definitions.
373
 */
374
function df_tools_blocks_alter_block_categories(array &$block_info) {
375
  // Create an associative array which maps default => custom block categories.
376
  $category_map = [
377
    'Embed' => t('Existing Content'),
378
    'Entity Block' => t('Existing Content'),
379
    'Commerce' => t('Forms'),
380
    'Lists (Views)' => t('Lists'),
381
    'Listes (Views)' => t('Lists'),
382
    'Listas (Views)' => t('Lists'),
383
    'Views' => t('Lists'),
384
    'AddToAny' => t('Social'),
385
    'Product hero' => t('Hero'),
386
    'Workbench moderation' => t('Hidden'),
387
    'User' => t('Hidden'),
388
    'Utilisateur' => t('Hidden'),
389
    'Usuario' => t('Hidden'),
390
    'Chaos tools' => t('Hidden'),
391
    'Help' => t('Hidden'),
392
    'core' => t('Hidden'),
393
    'System' => t('Hidden'),
394
    'Moderation Dashboard' => t('Hidden'),
395
    'Entity Browser' => t('Hidden'),
396
    'Facets' => t('Hidden'),
397
    'Facets summary (Experimental)' => t('Hidden'),
398
    'Responsive Preview' => t('Hidden'),
399
    'DF Tools Blocks' => t('Hidden'),
400
  ];
401
402
  $label_map = [
403
    'Content Embed' => t('Content'),
404
    'Media Embed' => t('Media'),
405
  ];
406
407
  foreach ($block_info as $key => $info) {
408
    // Retrieve the name of the block category.
409
    $category = $info['category'];
410
    $label = $info['label'];
411
412
    // Retrieve the untranslated name of the category if it has been translated.
413
    if ($category instanceof TranslatableMarkup) {
414
      $category = $category->getUntranslatedString();
415
    }
416
    if ($label instanceof TranslatableMarkup) {
417
      $label = $label->getUntranslatedString();
418
    }
419
420
    // Move all fields of the currently panelized entity into a
421
    // 'Current @Entity_Type' category. If the block is not a field on the
422
    // current entity, allow its category to be remapped.
423
    if ($category === '@entity') {
424
      $block_info[$key]['category'] = $info['category']->render() . ' Fields';
425
    }
426
    // Place Block Content entities into categories based on their type.
427
    elseif ($category === 'Custom') {
428
      list($type, $uuid) = explode(':', $block_info[$key]['plugin_id']);
429
      unset($type);
430
      $ids = \Drupal::entityQuery('block_content')
431
        ->condition('uuid', $uuid, '=')
432
        ->execute();
433
      if ($block = BlockContent::load(reset($ids))) {
0 ignored issues
show
Bug introduced by
It seems like $ids can also be of type integer; however, parameter $array of reset() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

433
      if ($block = BlockContent::load(reset(/** @scrutinizer ignore-type */ $ids))) {
Loading history...
434
        if ($bundle = BlockContentType::load($block->bundle())) {
435
          $block_info[$key]['category'] = $bundle->label();
436
        }
437
      }
438
    }
439
440
    if (isset($block_info[$key])) {
441
      if (isset($category_map[$category])) {
442
        // Already translated.
443
        $block_info[$key]['category'] = $category_map[$category];
444
      }
445
      elseif (is_string($block_info[$key]['category'])) {
446
        // Already translated.
447
        $block_info[$key]['category'] = $block_info[$key]['category'];
448
      }
449
      if (isset($label_map[$label])) {
450
        // Already translated.
451
        $block_info[$key]['label'] = $label_map[$label];
452
      }
453
      elseif (is_string($block_info[$key]['label'])) {
454
        // Already translated.
455
        $block_info[$key]['label'] = $block_info[$key]['label'];
456
      }
457
    }
458
459
    if ($label === 'Entity gallery' && $category === 'Entity Block') {
460
      $block_info[$key]['category'] = t('Hidden');
461
    }
462
463
    if ($label === 'Entity Gallery Browser') {
464
      $block_info[$key]['category'] = t('Existing Content');
465
      $block_info[$key]['label'] = t('Gallery');
466
    }
467
  }
468
}
469
470
/**
471
 * Implements hook_panels_ipe_blocks_alter().
472
 *
473
 * Improves Panelizer/Panels IPE UX by removing fields that cannot be placed.
474
 */
475
function df_tools_blocks_panels_ipe_blocks_alter(&$block_info) {
476
  // Re-sort blocks into specific categories.
477
  df_tools_blocks_alter_block_categories($block_info);
478
  // Filter out fields that aren't relevant for this entity.
479
  $request = \Drupal::request();
480
  $storage_id = str_replace('*', '', $request->attributes->get('panels_storage_id', ''));
481
  list($entity_type, $id) = explode(':', $storage_id);
482
  $entity_type_manager = \Drupal::entityTypeManager();
483
  if (!empty($entity_type) && !empty($id) && $entity_type_manager->hasDefinition($entity_type)) {
484
    if ($entity = $entity_type_manager->getStorage($entity_type)->load($id)) {
485
      foreach ($block_info as $key => $info) {
486
        if ($info['id'] === 'entity_field') {
487
          list($block_id, $block_entity_type, $field_name) = explode(':', $info['plugin_id']);
488
          unset($block_id);
489
          if ($block_entity_type !== $entity_type || ($entity instanceof FieldableEntityInterface && !$entity->hasField($field_name))) {
490
            unset($block_info[$key]);
491
          }
492
        }
493
      }
494
    }
495
  }
496
  $block_info = array_values($block_info);
497
}
498
499
/**
500
 * Form submission handler for df_tools_blocks_form_alter().
501
 */
502
function df_tools_blocks_block_content_replicate($form, FormStateInterface $form_state) {
503
  // Retrieve block content entity from form_state.
504
  $entity = $form_state->getFormObject()->getEntity();
0 ignored issues
show
Bug introduced by
The method getEntity() does not exist on Drupal\Core\Form\FormInterface. It seems like you code against a sub-type of Drupal\Core\Form\FormInterface such as Drupal\Tests\media_acquiadam\unit\FormStub or Drupal\Core\Entity\EntityFormInterface or Drupal\Core\Entity\EntityForm or Drupal\image_widget_crop...eWidgetCropExamplesForm or Drupal\workspaces\Form\WorkspaceDeleteForm or Drupal\workspaces\Form\WorkspaceDeployForm or Drupal\workspaces\Form\WorkspaceForm or Drupal\workspaces\Form\WorkspaceActivateForm or Drupal\Core\Entity\ContentEntityConfirmFormBase or Drupal\Core\Entity\EntityConfirmFormBase or Drupal\webform\Form\Webf...figEntityDeleteFormBase or Drupal\webform\Form\WebformSubmissionDeleteForm. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

504
  $entity = $form_state->getFormObject()->/** @scrutinizer ignore-call */ getEntity();
Loading history...
505
  // Extract a few values from the entity.
506
  $block_info = $entity->get('info')->value;
507
  $block_id = $entity->id();
508
  // Replicate the block content entity.
509
  if (\Drupal::service('df_tools_blocks.copier')->makeCopy($entity)) {
510
    $message = t('Block Content: copied @info [id:@id]', ['@info' => $block_info, '@id' => $block_id]);
511
    \Drupal::logger('df_tools_blocks')->info($message);
512
    drupal_set_message($message, 'status');
0 ignored issues
show
Deprecated Code introduced by
The function drupal_set_message() has been deprecated: in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

512
    /** @scrutinizer ignore-deprecated */ drupal_set_message($message, 'status');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
513
  }
514
  // Redirect to block list comes free!
515
}
516
517
/**
518
 * Implements hook_theme().
519
 */
520
function df_tools_blocks_theme($existing, $type, $theme, $path) {
521
  return [
522
    'code_block' => [
523
      'variables' => ['code' => NULL],
524
    ],
525
  ];
526
}
527