Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
novicell/dds_base / dds_base.theme
Size: Mime:
<?php

/**
 * @param array $suggestions
 * @param array $variables
 * Make block theme suggestions based on the region the block is placed in.
 * Ex. block--footer.html.twig or block--footer--[block-id].html.twig
 */
function dds_theme_suggestions_block_alter(array &$suggestions, array $variables) {
  if (!isset($variables['elements']['#configuration']['region'])) {
    // Get the block id and load the block entity
    $block_id = $variables['elements']['#id'];
    $block = \Drupal\block\Entity\Block::load($block_id);

    // Get the region
    $region = $block->getRegion();

    // Make the suggestion pattern block__[region]
    // If block_id is set make suggestion pattern block__[region]__[block_id]
    $suggestions[] = 'block__' . $region;
    if (isset($block_id)) {
      $suggestions[] = 'block__' . $region . '__' . $block_id;
    }
  }
}

function dds_theme_suggestions_input_alter(array &$suggestions, array $variables) {
  $element = $variables['element'];
  if($element['#type'] === 'button' || $element['#type'] === 'submit') {
    if(!empty($element['#name'])) {
      $suggestions[] = $variables['theme_hook_original'] . '__' . $element['#name'];
    }
  }
}