Move all files to deploying-php-ansible-ansistrano/demo/

This commit is contained in:
Oliver Davies 2025-10-03 22:04:20 +01:00
parent 986ba5097d
commit ad3af7d318
214 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,5 @@
name: Simple Message
description: Displays a simple message.
core_version_requirement: ^8 || ^9
type: module
package: Custom

View file

@ -0,0 +1,8 @@
services:
Drupal\Core\Messenger\MessengerInterface:
alias: messenger
Drupal\simple_message\DisplaySimpleMessage:
autowire: true
tags:
- { name: event_subscriber }

View file

@ -0,0 +1,47 @@
<?php
namespace Drupal\simple_message;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class DisplaySimpleMessage implements EventSubscriberInterface {
use StringTranslationTrait;
/**
* The Messenger service.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
private $messenger;
public function __construct(MessengerInterface $messenger) {
$this->messenger = $messenger;
}
public function displayMessage(GetResponseEvent $event) {
if (\Drupal::service('router.admin_context')->isAdminRoute()) {
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',
]));
}
/**
* @inheritDoc
*/
public static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = ['displayMessage'];
return $events;
}
}