Skip to content

Commit 89a0baa

Browse files
authored
Merge pull request #62 from wieni/feature/drupal-10-no-split
d10
2 parents d62271c + 97673e2 commit 89a0baa

23 files changed

Lines changed: 321 additions & 109 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"php": "^8.0",
14-
"drupal/core": "^9.1"
14+
"drupal/core": "^9.3 || ^10"
1515
},
1616
"require-dev": {
1717
"ergebnis/composer-normalize": "^2.0",
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: Wieni Page Cache
22
type: module
33
description: 'Caches pages for anonymous users, with more customizablity than the default page cache module'
4-
core: 8.x
5-
core_version_requirement: ^8 || ^9
4+
core_version_requirement: ^9.3 || ^10
65
package: Wieni

modules/wmpage_cache/wmpage_cache.install

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,6 @@ function wmpage_cache_schema()
7575

7676
function wmpage_cache_update_8001()
7777
{
78-
drupal_install_schema('wmpage_cache');
78+
// comment code because the table will already be installed during install of module
79+
//drupal_install_schema('wmpage_cache');
7980
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: Wieni Presenter
22
type: module
33
description: Adds support for creating & injecting view presenters on top of entity classes
4-
core: 8.x
5-
core_version_requirement: ^8 || ^9
4+
core_version_requirement: ^9.3 || ^10
65
package: Wieni
76
dependencies:
87
- wmtwig

modules/wmtwig/wmtwig.info.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: Wieni Twig
22
type: module
33
description: Improves the integration of Twig with component and entity-oriented projects
4-
core: 8.x
5-
core_version_requirement: ^8 || ^9
4+
core_version_requirement: ^9.3 || ^10
65
package: Wieni

src/Enhancer/InjectFrontControllerRouteEnhancer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Drupal\wmcontroller\Enhancer;
44

55
use Drupal\Core\Routing\EnhancerInterface;
6+
use Drupal\Core\Routing\RouteObjectInterface;
67
use Drupal\wmcontroller\Controller\FrontController;
7-
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
88
use Symfony\Component\HttpFoundation\Request;
99
use Symfony\Component\Routing\Route;
1010

src/EventSubscriber/CacheSubscriber.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
use Drupal\wmcontroller\WmcontrollerEvents;
1616
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1717
use Symfony\Component\HttpFoundation\Response;
18-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
19-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
20-
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
18+
use Symfony\Component\HttpKernel\Event\RequestEvent;
19+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
20+
use Symfony\Component\HttpKernel\Event\TerminateEvent;
2121
use Symfony\Component\HttpKernel\KernelEvents;
2222

2323
class CacheSubscriber implements EventSubscriberInterface
@@ -70,7 +70,7 @@ public static function getSubscribedEvents()
7070
return $events;
7171
}
7272

73-
public function onEnrichRequest(GetResponseEvent $event)
73+
public function onEnrichRequest(RequestEvent $event)
7474
{
7575
// Do a faster-than-drupal user and session lookup
7676
// Fills the Request attribute with:
@@ -80,9 +80,9 @@ public function onEnrichRequest(GetResponseEvent $event)
8080
$this->enrichRequest->enrichRequest($event->getRequest());
8181
}
8282

83-
public function onGetCachedResponse(GetResponseEvent $event)
83+
public function onGetCachedResponse(RequestEvent $event)
8484
{
85-
if (!$event->isMasterRequest()) {
85+
if (!$event->isMainRequest()) {
8686
return;
8787
}
8888

@@ -111,13 +111,13 @@ public function onGetCachedResponse(GetResponseEvent $event)
111111
}
112112
}
113113

114-
public function onResponse(FilterResponseEvent $event)
114+
public function onResponse(ResponseEvent $event)
115115
{
116116
$request = $event->getRequest();
117117
$response = $event->getResponse();
118118

119119
if (
120-
!$event->isMasterRequest()
120+
!$event->isMainRequest()
121121
|| $response instanceof CachedResponse
122122
|| empty($response->getContent())
123123
) {
@@ -173,13 +173,13 @@ public function onTags(CacheTagsEvent $event)
173173
}
174174
}
175175

176-
public function onTerminate(PostResponseEvent $event)
176+
public function onTerminate(TerminateEvent $event)
177177
{
178178
$request = $event->getRequest();
179179
$response = $event->getResponse();
180180

181181
if (
182-
!$event->isMasterRequest()
182+
!$event->isMainRequest()
183183
|| !$response->isCacheable()
184184
) {
185185
return;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Drupal\wmcontroller\EventSubscriber;
4+
5+
use Drupal\wmcontroller\Event\PresentedEvent;
6+
use Drupal\wmcontroller\WmcontrollerEvents;
7+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8+
9+
class TemplateParameterCacheableDependencySubscriber implements EventSubscriberInterface
10+
{
11+
protected static $dispatched = [];
12+
13+
public static function getSubscribedEvents(): array
14+
{
15+
$events[WmcontrollerEvents::PRESENTED][] = ['onTemplateParameter'];
16+
17+
return $events;
18+
}
19+
20+
public function onTemplateParameter(PresentedEvent $event): void
21+
{
22+
$value = $event->getItem();
23+
24+
if (!($value instanceof \Drupal\Core\Entity\EntityInterface)) {
25+
return;
26+
}
27+
28+
$key = sprintf('%s:%s', $value->getEntityTypeId(), $value->id());
29+
if (isset(self::$dispatched[$key])) {
30+
return;
31+
}
32+
33+
self::$dispatched[$key] = true;
34+
\Drupal::service('wmcontroller.cache.dispatcher')
35+
->dispatchPresented($value);
36+
}
37+
38+
}

src/EventSubscriber/ViewRendererSubscriber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Drupal\wmcontroller\ViewBuilder\ViewBuilder;
66
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
7-
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
7+
use Symfony\Component\HttpKernel\Event\ViewEvent;
88
use Symfony\Component\HttpKernel\KernelEvents;
99

1010
class ViewRendererSubscriber implements EventSubscriberInterface
@@ -17,7 +17,7 @@ public static function getSubscribedEvents()
1717
return $events;
1818
}
1919

20-
public function renderView(GetResponseForControllerResultEvent $event)
20+
public function renderView(ViewEvent $event)
2121
{
2222
$result = $event->getControllerResult();
2323
if ($result instanceof ViewBuilder) {

src/Http/Middleware/Cache.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ public function __construct(
2626

2727
public function handle(
2828
Request $request,
29-
$type = self::MASTER_REQUEST,
29+
$type = self::MAIN_REQUEST,
3030
$catch = true
31-
) {
32-
if ($type !== static::MASTER_REQUEST) {
31+
): \Symfony\Component\HttpFoundation\Response
32+
{
33+
if ($type !== static::MAIN_REQUEST) {
3334
return $this->next->handle($request, $type, $catch);
3435
}
3536

0 commit comments

Comments
 (0)