class OliveroPreRender

Same name in other branches
  1. 10 core/themes/olivero/src/OliveroPreRender.php \Drupal\olivero\OliveroPreRender
  2. 11.x core/themes/olivero/src/OliveroPreRender.php \Drupal\olivero\OliveroPreRender

Implements trusted prerender callbacks for the Olivero theme.

@internal

Hierarchy

Expanded class hierarchy of OliveroPreRender

1 file declares its use of OliveroPreRender
olivero.theme in core/themes/olivero/olivero.theme
Functions to support theming in the Olivero theme.

File

core/themes/olivero/src/OliveroPreRender.php, line 12

Namespace

Drupal\olivero
View source
class OliveroPreRender implements TrustedCallbackInterface {
    
    /**
     * Prerender callback for text_format elements.
     */
    public static function textFormat($element) {
        $element['format']['#attributes']['class'][] = 'filter-wrapper';
        $element['format']['format']['#wrapper_attributes']['class'][] = 'form-item--editor-format';
        $element['format']['format']['#attributes']['class'][] = 'filter-list';
        $element['format']['format']['#attributes']['class'][] = 'form-element--small';
        $element['format']['format']['#attributes']['class'][] = 'form-element--editor-format';
        $element['format']['guidelines']['#attributes']['class'][] = 'filter-guidelines';
        $element['format']['help']['#attributes']['class'][] = 'filter-help';
        return $element;
    }
    
    /**
     * Prerender callback for status_messages placeholder.
     *
     * @param array $element
     *   A renderable array.
     *
     * @return array
     *   The updated renderable array containing the placeholder.
     */
    public static function messagePlaceholder(array $element) {
        if (isset($element['fallback']['#markup'])) {
            $element['fallback']['#markup'] = '<div data-drupal-messages-fallback class="hidden messages-list"></div>';
        }
        return $element;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function trustedCallbacks() {
        return [
            'textFormat',
            'messagePlaceholder',
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
OliveroPreRender::messagePlaceholder public static function Prerender callback for status_messages placeholder.
OliveroPreRender::textFormat public static function Prerender callback for text_format elements.
OliveroPreRender::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.

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