drowl_paragraphs_bs-1.x-dev/modules/drowl_paragraphs_bs_type_image_text/drowl_paragraphs_bs_type_image_text.module

modules/drowl_paragraphs_bs_type_image_text/drowl_paragraphs_bs_type_image_text.module
<?php

/**
 * @file
 * Drowl_paragraphs_bs_type_image_text module.
 */

use Drupal\Core\Template\Attribute;

/**
 * Prepared variables for paragraph output.
 */
function drowl_paragraphs_bs_type_image_text_preprocess_paragraph(&$variables) {
  if ($variables['paragraph']->bundle() == 'image_text') {
    // Get icon & icon combo specific ui_styles so we can apply them to
    // this specific wrappers, instead the paragraph wrapper.
    $variables['image_wrapper_attributes'] = new Attribute();
    if (isset($variables['attributes']['class'])) {
      foreach ($variables['attributes']['class'] as $class) {
        if (str_starts_with($class, 'img-wrapper__')) {
          $variables['attributes']->removeClass($class);
          $variables['image_wrapper_attributes']->addClass(str_replace('img-wrapper__', '', $class));
        }
        elseif (str_starts_with($class, 'img-') || str_starts_with($class, 'float-') || str_starts_with($class, 'ratio') || str_starts_with($class, 'w-')) {
          $variables['attributes']->removeClass($class);
          $variables['image_wrapper_attributes']->addClass($class);
        }
      }
    }
  }
}

/**
 * Implements hook_theme().
 */
function drowl_paragraphs_bs_type_image_text_theme($existing, $type, $theme, $path) {
  $templates = $path . '/templates';
  return [
    'paragraph__drowl_paragraphs_bs__image_text' => [
      'base hook' => 'paragraph',
      'path' => $templates,
    ],
  ];
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc