CustomHTMLBlockBase.php in Content Planner 8
File
src/Plugin/DashboardBlock/CustomHTMLBlockBase.php
View source
<?php
namespace Drupal\content_planner\Plugin\DashboardBlock;
use Drupal\content_planner\DashboardBlockBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\HttpFoundation\Request;
abstract class CustomHTMLBlockBase extends DashboardBlockBase {
public function build() {
$build = [];
$config = $this
->getConfiguration();
if (isset($config['plugin_specific_config']['content'])) {
$build = [
'#markup' => check_markup($config['plugin_specific_config']['content']['value'], $config['plugin_specific_config']['content']['format']),
];
}
return $build;
}
public function getConfigSpecificFormFields(FormStateInterface &$form_state, Request &$request, array $block_configuration) {
$form = [];
if (!empty($block_configuration['plugin_specific_config']['content']['value'])) {
$default_value = $block_configuration['plugin_specific_config']['content']['value'];
}
else {
$default_value = '';
}
$form['content'] = [
'#type' => 'text_format',
'#title' => t('Content'),
'#format' => 'full_html',
'#default_value' => $default_value,
];
return $form;
}
}