summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/layout_builder/src/LayoutBuilderHighlightTrait.php
blob: af0b2b7760f2f41bfc4033eb368f349924b815bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php

namespace Drupal\layout_builder;

/**
 * A trait for generating IDs used to highlight active UI elements.
 */
trait LayoutBuilderHighlightTrait {

  /**
   * Provides the ID used to highlight the active Layout Builder UI element.
   *
   * @param int $delta
   *   The section the block is in.
   * @param string $region
   *   The section region in which the block is placed.
   *
   * @return string
   *   The highlight ID of the block.
   */
  protected function blockAddHighlightId($delta, $region) {
    return "block-$delta-$region";
  }

  /**
   * Provides the ID used to highlight the active Layout Builder UI element.
   *
   * @param string $uuid
   *   The uuid of the block.
   *
   * @return string
   *   The highlight ID of the block.
   */
  protected function blockUpdateHighlightId($uuid) {
    return $uuid;
  }

  /**
   * Provides the ID used to highlight the active Layout Builder UI element.
   *
   * @param int $delta
   *   The location of the section.
   *
   * @return string
   *   The highlight ID of the section.
   */
  protected function sectionAddHighlightId($delta) {
    return "section-$delta";
  }

  /**
   * Provides the ID used to highlight the active Layout Builder UI element.
   *
   * @param int $delta
   *   The location of the section.
   *
   * @return string
   *   The highlight ID of the section.
   */
  protected function sectionUpdateHighlightId($delta) {
    return "section-update-$delta";
  }

}