LayoutBuilderHighlightTrait.php

Same filename in other branches
  1. 9 core/modules/layout_builder/src/LayoutBuilderHighlightTrait.php
  2. 10 core/modules/layout_builder/src/LayoutBuilderHighlightTrait.php
  3. 11.x core/modules/layout_builder/src/LayoutBuilderHighlightTrait.php

Namespace

Drupal\layout_builder

File

core/modules/layout_builder/src/LayoutBuilderHighlightTrait.php

View source
<?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 string $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 string $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 string $delta
     *   The location of the section.
     *
     * @return string
     *   The highlight ID of the section.
     */
    protected function sectionUpdateHighlightId($delta) {
        return "section-update-{$delta}";
    }

}

Traits

Title Deprecated Summary
LayoutBuilderHighlightTrait A trait for generating IDs used to highlight active UI elements.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.