DynamicBlockField.php in Display Suite 8.2
File
src/Plugin/DsField/DynamicBlockField.php
View source
<?php
namespace Drupal\ds\Plugin\DsField;
use Drupal\views\Plugin\Block\ViewsBlock;
class DynamicBlockField extends BlockBase {
protected function blockPluginId() {
$definition = $this
->getPluginDefinition();
return $definition['properties']['block'];
}
protected function blockConfig() {
$block_config = array();
$definition = $this
->getPluginDefinition();
if (isset($definition['properties']['config'])) {
$block_config = $definition['properties']['config'];
}
return $block_config;
}
public function getTitle() {
$field = $this
->getFieldConfiguration();
$title = $field['title'];
if (isset($field['properties']['use_block_title']) && $field['properties']['use_block_title'] == TRUE) {
$block = $this
->getBlock();
if ($block instanceof ViewsBlock) {
$block_build = $block
->build();
if (!empty($block_build['#title'])) {
$title = $block_build['#title'];
}
}
else {
$title = $block
->label();
}
}
return $title;
}
}