ds-8.x-3.9/modules/ds_extras/src/Plugin/Block/DsRegionBlock.php

modules/ds_extras/src/Plugin/Block/DsRegionBlock.php
<?php

namespace Drupal\ds_extras\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Markup;

/**
 * Provides the region block plugin.
 *
 * @Block(
 *   id = "ds_region_block",
 *   admin_label = @Translation("Ds region block"),
 *   category = @Translation("Display Suite"),
 *   deriver = "Drupal\ds_extras\Plugin\Derivative\DsRegionBlock"
 * )
 */
class DsRegionBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $id = $this->getDerivativeId();
    $data = drupal_static('ds_block_region');

    if (!empty($data[$id])) {
      $output = '';

      foreach (Element::children($data[$id]) as $key) {
        if (!empty($data[$id][$key])) {
          $output .= \Drupal::service('renderer')->render($data[$id][$key]);
        }
      }

      return ['#markup' => Markup::create($output)];
    }
    else {
      return [];
    }
  }

}

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

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