Skip to content

Commit

Permalink
Bump requirements to PHP 8.0 and Drupal 9.1 (#57)
Browse files Browse the repository at this point in the history
* Fix "Required argument $strippedHeaders after optional argument"

Deprecated in php8

* Remove deprecation warnings when dispatching Events

See https://www.drupal.org/node/3159012 and https://www.drupal.org/node/3154407

* Update changelog

* Bump required php version to 8.0
  • Loading branch information
RobinHoutevelts authored Aug 24, 2021
1 parent 8412376 commit 0659a46
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .php_cs.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

use Wieni\wmcodestyle\PhpCsFixer\Config\Factory;
use Wieni\wmcodestyle\PhpCsFixer\Config\RuleSet\Php71;
use Wieni\wmcodestyle\PhpCsFixer\Config\RuleSet\Php80;

$config = Factory::fromRuleSet(new Php71);
$config = Factory::fromRuleSet(new Php80);

$config->getFinder()
->ignoreVCSIgnored(true)
Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## Unreleased

## [1.0.0] - 2021-08-24
### Added
- Add support for all entities with canonical routes
- Add issue & pull request templates
- Add coding standard fixers
- Add Drupal 9 support

### Changed
- Increase PHP dependency to 7.1
- Increase PHP dependency to 8.0
- Update module name & description
- Make bundle-specific controllers optional, falling back to the default
controller
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wieni/wmcontroller",
"type": "drupal-module",
"description": "Adds support for bundle-specific controllers for Drupal 8 entities.",
"description": "Adds support for bundle-specific controllers for Drupal 9 entities.",
"license": "MIT",
"authors": [
{
Expand All @@ -10,12 +10,12 @@
}
],
"require": {
"php": ">=7.1.0",
"drupal/core": "^8.6 || ^9.0"
"php": "^8.0",
"drupal/core": "^9.1"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.0",
"wieni/wmcodestyle": "^1.0"
"wieni/wmcodestyle": "^1.7"
},
"extra": {
"drush": {
Expand Down
2 changes: 1 addition & 1 deletion src/Event/CacheInsertEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\wmcontroller\Event;

use Drupal\wmcontroller\Entity\Cache;
use Symfony\Component\EventDispatcher\Event;
use Drupal\Component\EventDispatcher\Event;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

Expand Down
2 changes: 1 addition & 1 deletion src/Event/CacheTagsEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Drupal\wmcontroller\Event;

use Symfony\Component\EventDispatcher\Event;
use Drupal\Component\EventDispatcher\Event;

class CacheTagsEvent extends Event
{
Expand Down
2 changes: 1 addition & 1 deletion src/Event/EntityPresentedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\wmcontroller\Event;

use Drupal\Core\Entity\EntityInterface;
use Symfony\Component\EventDispatcher\Event;
use Drupal\Component\EventDispatcher\Event;

class EntityPresentedEvent extends Event
{
Expand Down
2 changes: 1 addition & 1 deletion src/Event/MainEntityEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Drupal\wmcontroller\Event;

use Drupal\Component\EventDispatcher\Event;
use Drupal\Core\Entity\EntityInterface;
use Symfony\Component\EventDispatcher\Event;

class MainEntityEvent extends Event
{
Expand Down
2 changes: 1 addition & 1 deletion src/Event/PresentedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Drupal\wmcontroller\Event;

use Symfony\Component\EventDispatcher\Event;
use Drupal\Component\EventDispatcher\Event;

class PresentedEvent extends Event
{
Expand Down
2 changes: 1 addition & 1 deletion src/Event/ValidationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Drupal\Core\Access\AccessResult;
use Drupal\wmcontroller\Service\Cache\Validation\ValidationResult;
use Symfony\Component\EventDispatcher\Event;
use Drupal\Component\EventDispatcher\Event;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

Expand Down
2 changes: 1 addition & 1 deletion src/EventSubscriber/CacheSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(
Validation $validation,
EnrichRequest $enrichRequest,
MaxAgeInterface $maxAgeStrategy,
$addHeader = false,
bool $addHeader,
array $strippedHeaders
) {
$this->manager = $manager;
Expand Down
8 changes: 4 additions & 4 deletions src/Http/Middleware/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Drupal\wmcontroller\WmcontrollerEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;

class Cache implements HttpKernelInterface
Expand Down Expand Up @@ -33,11 +33,11 @@ public function handle(
return $this->next->handle($request, $type, $catch);
}

$event = new GetResponseEvent($this, $request, $type);
$event = new RequestEvent($this, $request, $type);

$this->dispatcher->dispatch(
WmcontrollerEvents::CACHE_HANDLE,
$event
$event,
WmcontrollerEvents::CACHE_HANDLE
);

if ($event->hasResponse()) {
Expand Down
24 changes: 12 additions & 12 deletions src/Service/Cache/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function dispatchMainEntity(EntityInterface $entity)
{
$event = new MainEntityEvent($entity);
$this->dispatcher->dispatch(
WmcontrollerEvents::MAIN_ENTITY_RENDER,
$event
$event,
WmcontrollerEvents::MAIN_ENTITY_RENDER
);

return $event;
Expand All @@ -46,8 +46,8 @@ public function dispatchPresented(EntityInterface $entity)
{
$event = new EntityPresentedEvent($entity);
$this->dispatcher->dispatch(
WmcontrollerEvents::ENTITY_PRESENTED,
$event
$event,
WmcontrollerEvents::ENTITY_PRESENTED
);

return $event;
Expand All @@ -58,8 +58,8 @@ public function dispatchTags(array $tags)
{
$event = new CacheTagsEvent($tags);
$this->dispatcher->dispatch(
WmcontrollerEvents::CACHE_TAGS,
$event
$event,
WmcontrollerEvents::CACHE_TAGS
);

return $event;
Expand All @@ -74,8 +74,8 @@ public function dispatchCacheInsertEvent(
) {
$event = new CacheInsertEvent($cache, $tags, $request, $response);
$this->dispatcher->dispatch(
WmcontrollerEvents::CACHE_INSERT,
$event
$event,
WmcontrollerEvents::CACHE_INSERT
);

return $event;
Expand All @@ -90,8 +90,8 @@ public function dispatchRequestCacheablityValidation(Request $request)
CacheableRequestResult::class
);
$this->dispatcher->dispatch(
WmcontrollerEvents::VALIDATE_CACHEABILITY_REQUEST,
$event
$event,
WmcontrollerEvents::VALIDATE_CACHEABILITY_REQUEST
);
return $event;
}
Expand All @@ -105,8 +105,8 @@ public function dispatchResponseCacheablityValidation(Request $request, Response
CacheableResponseResult::class
);
$this->dispatcher->dispatch(
WmcontrollerEvents::VALIDATE_CACHEABILITY_RESPONSE,
$event
$event,
WmcontrollerEvents::VALIDATE_CACHEABILITY_RESPONSE
);
return $event;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Twig/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function display(array $context, array $blocks = [])
foreach ($context as $k => $var) {
$event = new PresentedEvent($var);
$this->getDispatcher()->dispatch(
WmcontrollerEvents::PRESENTED,
$event
$event,
WmcontrollerEvents::PRESENTED
);

$context[$k] = $event->getItem();
Expand Down

0 comments on commit 0659a46

Please sign in to comment.