Compare commits
No commits in common. "1.0.0" and "2.x" have entirely different histories.
2 changed files with 17 additions and 13 deletions
8
composer.json
Normal file
8
composer.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "drupal/simple_message",
|
||||||
|
"description": "Displays a simple message.",
|
||||||
|
"type": "drupal-module",
|
||||||
|
"require": {
|
||||||
|
"php": "^7.4"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Drupal\simple_message;
|
namespace Drupal\simple_message;
|
||||||
|
|
||||||
|
use Drupal\Core\Config\Config;
|
||||||
use Drupal\Core\Routing\AdminContext;
|
use Drupal\Core\Routing\AdminContext;
|
||||||
use Drupal\Core\Messenger\MessengerInterface;
|
use Drupal\Core\Messenger\MessengerInterface;
|
||||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||||
|
@ -14,35 +17,28 @@ final class DisplaySimpleMessage implements EventSubscriberInterface {
|
||||||
|
|
||||||
use StringTranslationTrait;
|
use StringTranslationTrait;
|
||||||
|
|
||||||
private $messenger;
|
private MessengerInterface $messenger;
|
||||||
private $adminContext;
|
private AdminContext $adminContext;
|
||||||
private $config;
|
private Config $config;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
MessengerInterface $messenger,
|
MessengerInterface $messenger,
|
||||||
AdminContext $adminContext,
|
AdminContext $adminContext,
|
||||||
ConfigFactoryInterface $configFactory
|
ConfigFactoryInterface $configFactory
|
||||||
) {
|
) {
|
||||||
$this->messenger = $messenger;
|
$this->messenger = $messenger;
|
||||||
$this->adminContext = $adminContext;
|
$this->adminContext = $adminContext;
|
||||||
$this->config = $configFactory->get('simple_message.config');
|
$this->config = $configFactory->get('simple_message.config');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function displayMessage(GetResponseEvent $event) {
|
public function displayMessage(GetResponseEvent $event): void {
|
||||||
if ($this->adminContext->isAdminRoute()) {
|
if ($this->adminContext->isAdminRoute()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($message = $this->config->get('message')) {
|
if ($message = $this->config->get('message')) {
|
||||||
$this->messenger->addMessage($message);
|
$this->messenger->addMessage($this->t($message));
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
$this->messenger->addMessage($this->t('This site is running on a <a href="@vagrant">Vagrant</a> server, deployed with <a href="@ansible">Ansible</a> and <a href="@ansistrano">Ansistrano</a>.', [
|
|
||||||
'@ansible' => 'https://ansible.com',
|
|
||||||
'@ansistrano' => 'https://ansistrano.com',
|
|
||||||
'@vagrant' => 'https://vagrantup.com',
|
|
||||||
]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue