FooterMessageBlock.php in Footer Message 8
File
src/Plugin/Block/FooterMessageBlock.php
View source
<?php
namespace Drupal\footer_message\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FooterMessageBlock extends BlockBase implements ContainerFactoryPluginInterface {
protected $configFactory;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactory $config_factory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configFactory = $config_factory;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory'));
}
public function build() {
$config = $this->configFactory
->get('footer_message.settings');
$message = $config
->get('footer_message_msg');
$format = $config
->get('footer_message_format');
return array(
'#type' => 'markup',
'#markup' => check_markup(isset($message) ? $message : '', $format),
'#cache' => [
'tags' => [
'block:footer_message',
],
],
);
}
}