Reaction 'Body class' enable token replacement

Created on 19 March 2024, 9 months ago

XXX [current-page:url:unaliased:path] YYY → XXX node-6 YYY
\context\src\Plugin\ContextReaction\BodyClass.php

  public function execute(array &$vars = []) {
    $context_body_class = explode(' ', $this->getConfiguration()['body_class']);
    $context_body_class = array_map(function($val) {
	return (str_starts_with($val, '[')) ? trim(str_replace(['/'],['-'], \Drupal::token()->replace($val)), '-') : $val; }, $context_body_class);
    return ['class' => $context_body_class];
    /*return [
      'class' => explode(' ', $this->getConfiguration()['body_class']),
    ];*/
  }

Feature request
Status

Active

Version

5.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024