Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
TTWEBTAKEN-196: Add Drupal 10 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaelvdwalle committed Oct 16, 2023
1 parent cad8fb4 commit 245fdc6
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(TranslationInterface $translation) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
return [
PermissionEventInterface::EVENT_NAME => [['provideDefaultOgPermissions']],
];
Expand Down
2 changes: 1 addition & 1 deletion og_sm_admin_menu/src/Routing/RouteSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function alterRoutes(RouteCollection $collection) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
$events = [];
$events[RoutingEvents::ALTER] = ['onAlterRoutes'];

Expand Down
2 changes: 1 addition & 1 deletion og_sm_config/src/Config/SiteConfigCollectionNameTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function createConfigCollectionName(NodeInterface $site) {
*
* @see self::createConfigCollectionName()
*/
protected function getSiteIdFromCollectionName($collection):int {
protected function getSiteIdFromCollectionName($collection): int {
$matches = [];
if (!preg_match('/^og_sm\.(.*)\.(\d*)$/', $collection, $matches)) {
throw new \InvalidArgumentException("'$collection' is not a valid site override collection");
Expand Down
9 changes: 6 additions & 3 deletions og_sm_config/src/Config/SiteConfigFactoryOverride.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Drupal\og_sm\Event\SiteEvents;
use Drupal\og_sm\OgSm;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;

/**
Expand Down Expand Up @@ -126,7 +125,7 @@ public function getStorage(NodeInterface $site) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
$events = parent::getSubscribedEvents();
$events[KernelEvents::REQUEST][] = ['onKernelRequestSetSite'];
// Set the priority of the delete event low, we only want to remove the
Expand Down Expand Up @@ -189,7 +188,11 @@ public function onConfigRename(ConfigRenameEvent $event) {
* The Event to process.
*/
public function onKernelRequestSetSite(RequestEvent $event) {
if ($event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) {
// Using hardcoded value 1 to ensure compatibility with both Drupal 9
// HttpKernelInterface::MASTER_REQUEST and Drupal 10,
// HttpKernelInterface::MAIN_REQUEST as described in more detail at
// https://www.drupal.org/node/3236639
if ($event->getRequestType() !== 1) {
return;
}
$currentSite = OgSm::siteManager()->currentSite();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GroupPermissionEventSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
return [
PermissionEventInterface::EVENT_NAME => [['provideDefaultOgPermissions']],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
return [
PermissionEventInterface::EVENT_NAME => [['provideDefaultOgPermissions']],
];
Expand Down
2 changes: 1 addition & 1 deletion og_sm_path/src/EventSubscriber/EventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class EventSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
$events = [];
$events[AjaxPathEvents::COLLECT][] = 'onAjaxPathCollection';

Expand Down
2 changes: 1 addition & 1 deletion og_sm_path/src/EventSubscriber/SiteSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(SitePathManagerInterface $site_path_manager, ModuleH
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
$events = [];
$events[SiteEvents::INSERT][] = 'onSiteInsert';
$events[SiteEvents::UPDATE][] = 'onSiteUpdate';
Expand Down
2 changes: 1 addition & 1 deletion og_sm_path/src/EventSubscriber/SiteTypeSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
$events = [];
$events[SiteTypeEvents::ADD][] = 'onSiteTypeAdd';
$events[SiteTypeEvents::REMOVE][] = 'onSiteTypeRemove';
Expand Down
2 changes: 1 addition & 1 deletion og_sm_routing/src/EventSubscriber/SiteRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
$events = [];
$events[RoutingEvents::DYNAMIC] = 'onDynamicRouteEvent';
return $events;
Expand Down
2 changes: 1 addition & 1 deletion og_sm_routing/src/SiteRoutesSubscriberBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract protected function collectRoutes(RouteCollection $collection, NodeInter
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
$events = [];
$events[SiteRoutingEvents::COLLECT] = 'onCollectRoutes';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SiteRoutesSubscriber extends SiteRoutesSubscriberBase {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
$events = parent::getSubscribedEvents();
$events[SiteRoutingEvents::ALTER] = 'alterRoutes';
return $events;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(RouteBuilderInterface $route_builder) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
$events[SiteEvents::INSERT][] = 'onSiteInsert';
$events[SiteEvents::DELETE][] = 'onSiteDelete';
$events[SiteEvents::UPDATE][] = 'onSiteUpdate';
Expand Down
2 changes: 1 addition & 1 deletion og_sm_taxonomy/src/EventSubscriber/SiteEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(SiteManagerInterface $site_manager) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
$events = [];
$events[SiteEvents::DELETE][] = 'onSiteDelete';

Expand Down
2 changes: 1 addition & 1 deletion src/EventSubscriber/GroupPermissionEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(TranslationInterface $translation) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents():array {
public static function getSubscribedEvents(): array {
return [
PermissionEventInterface::EVENT_NAME => [['provideDefaultOgPermissions']],
];
Expand Down

0 comments on commit 245fdc6

Please sign in to comment.