Skip to content

Commit

Permalink
Merge branch 'main' into docs/next-drupal-docs-update
Browse files Browse the repository at this point in the history
  • Loading branch information
backlineint authored Oct 11, 2024
2 parents 239b578 + 1cda615 commit b3e6c77
Show file tree
Hide file tree
Showing 32 changed files with 87 additions and 103 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
phpunit:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
matrix:
# Supported PHP versions: https://www.drupal.org/docs/getting-started/system-requirements/php-requirements
Expand All @@ -22,15 +22,21 @@ jobs:
- "10.0.x"
- "10.1.x"
- "10.2.x"
- "10.3.x"
- "11.0.x"
exclude:
- drupal: "10.0.x"
php: "8.3"
- drupal: "10.1.x"
php: "8.3"
- drupal: "11.0.x"
php: "8.1"
- drupal: "11.0.x"
php: "8.2"
name: Drupal ${{ matrix.drupal }} - PHP ${{ matrix.php }}
services:
mysql:
image: mysql:5.7
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: db
Expand Down
8 changes: 5 additions & 3 deletions modules/next/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ include:
#
# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml
################
# variables:
# SKIP_ESLINT: '1'

variables:
# SKIP_ESLINT: '1'
OPT_IN_TEST_PREVIOUS_MINOR: 1
OPT_IN_TEST_NEXT_MINOR: 1
OPT_IN_TEST_NEXT_MAJOR: 1
###################################################################################
#
# *
Expand Down
2 changes: 1 addition & 1 deletion modules/next/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"drupal/subrequests": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0 || ^7.0 || ^8.0 || ^9.0"
"phpunit/phpunit": "^9 || ^10"
}
}
2 changes: 1 addition & 1 deletion modules/next/modules/next_extras/next_extras.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Next.js Extras (Experimental)
description: Adds extra (mostly experiemental) functionality to Next.js module
type: module
core_version_requirement: ^9 || ^10
core_version_requirement: ^10 || ^11
package: Web services
dependencies:
- next:next
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public function invalidatePath(string $path, array $sites): void {
}
}
catch (RequestException $exception) {
watchdog_exception('next_extras', $exception);
// Using logger service to log the exception.
$this->logger->error($exception->getMessage());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/next/modules/next_graphql/next_graphql.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'Next.js GraphQL'
type: module
description: 'GraphQL for Next.js'
core_version_requirement: ^9 || ^10
core_version_requirement: ^10 || ^11
package: Web services
dependencies:
- graphql:graphql
Expand Down
2 changes: 1 addition & 1 deletion modules/next/modules/next_jsonapi/next_jsonapi.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'Next.js JSON:API'
type: module
description: 'JSON:API Helpers for Next.js'
core_version_requirement: ^9 || ^10
core_version_requirement: ^10 || ^11
package: Web services
dependencies:
- decoupled_router:decoupled_router
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class NextJsonapiServiceProvider extends ServiceProviderBase {
*/
public function alter(ContainerBuilder $container) {
/** @var \Symfony\Component\DependencyInjection\Definition $definition */

if ($container->hasDefinition('jsonapi.entity_resource')) {
$definition = $container->getDefinition('jsonapi.entity_resource');
$definition->setClass('Drupal\next_jsonapi\Controller\EntityResource');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Drupal\user\Entity\User;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -45,7 +45,6 @@ protected function setUp(): void {
$this->installEntitySchema('node');
$this->installEntitySchema('user');
$this->installConfig(['filter', 'next']);
$this->installSchema('system', ['sequences']);
$this->installSchema('node', ['node_access']);

$type = NodeType::create([
Expand Down Expand Up @@ -91,14 +90,14 @@ public function testPageLimit() {

// Default using \Drupal\jsonapi\Query\OffsetPage::SIZE_MAX.
$request = Request::create('/jsonapi/node/article');
$request->query = new ParameterBag();
$request->query = new InputBag();
$response = $entity_resource->getCollection($resource_type, $request);
$data = $response->getResponseData()->getData();
$this->assertSame(50, $data->count());

// With page limit.
$request = Request::create('/jsonapi/node/article');
$request->query = new ParameterBag([
$request->query = new InputBag([
'page' => [
'limit' => 10,
],
Expand All @@ -109,7 +108,7 @@ public function testPageLimit() {

// With page limit over size max.
$request = Request::create('/jsonapi/node/article');
$request->query = new ParameterBag([
$request->query = new InputBag([
'page' => [
'limit' => 100,
],
Expand All @@ -120,7 +119,7 @@ public function testPageLimit() {

// With page limit and offset.
$request = Request::create('/jsonapi/node/article');
$request->query = new ParameterBag([
$request->query = new InputBag([
'page' => [
'offset' => 2,
'limit' => 5,
Expand All @@ -132,7 +131,7 @@ public function testPageLimit() {

// With fields as sparse fieldset.
$request = Request::create('/jsonapi/node/article');
$request->query = new ParameterBag([
$request->query = new InputBag([
'fields' => [
'node--article' => 'title',
],
Expand All @@ -143,7 +142,7 @@ public function testPageLimit() {

// Using sparse fieldset path override.
$request = Request::create('/jsonapi/node/article');
$request->query = new ParameterBag([
$request->query = new InputBag([
'fields' => [
'node--article' => 'path,title',
],
Expand All @@ -154,7 +153,7 @@ public function testPageLimit() {

// Using sparse fieldset path override and limit.
$request = Request::create('/jsonapi/node/article');
$request->query = new ParameterBag([
$request->query = new InputBag([
'fields' => [
'node--article' => 'path,title',
],
Expand All @@ -168,7 +167,7 @@ public function testPageLimit() {

// Using sparse fieldset path override and limit.
$request = Request::create('/jsonapi/node/article');
$request->query = new ParameterBag([
$request->query = new InputBag([
'fields' => [
'node--article' => 'path,title',
],
Expand Down
2 changes: 1 addition & 1 deletion modules/next/modules/next_jwt/next_jwt.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Next.js JWT (Experimental)
type: module
description: 'Generates preview URLs using JSON Web Token'
core_version_requirement: ^9 || ^10
core_version_requirement: ^10 || ^11
package: Web services
dependencies:
- next:next
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(AccountInterface $current_user, NextSettingsManagerI
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events[JwtAuthEvents::GENERATE][] = ['setStandardClaims', 100];
$events[JwtAuthEvents::GENERATE][] = ['setDrupalClaims', 99];
return $events;
Expand Down
2 changes: 1 addition & 1 deletion modules/next/next.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Next.js
description: Next.js + Drupal for Incremental Static Regeneration and Draft mode.
type: module
core_version_requirement: ^9 || ^10
core_version_requirement: ^10 || ^11
package: Web services
configure: entity.next_site.collection
dependencies:
Expand Down
1 change: 1 addition & 0 deletions modules/next/next.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
'@config.factory',
'@plugin.manager.next.site_previewer',
'@plugin.manager.next.preview_url_generator',
'@logger.channel.next',
]
next.preview_secret_generator:
class: Drupal\next\PreviewSecretGenerator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EntityActionEventRevalidateSubscriber extends EntityActionEventSubscriberB
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events[EntityEvents::ENTITY_ACTION] = ['onAction'];
return $events;
}
Expand Down
33 changes: 7 additions & 26 deletions modules/next/src/Form/NextSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Drupal\next\Form;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\SubformState;
Expand All @@ -22,7 +21,7 @@ class NextSettingsForm extends ConfigFormBase {
*
* @var \Drupal\next\Plugin\SitePreviewerManagerInterface
*/
protected $sitePreviewerManager;
protected SitePreviewerManagerInterface $sitePreviewerManager;

/**
* The preview url generator manager.
Expand All @@ -31,34 +30,16 @@ class NextSettingsForm extends ConfigFormBase {
*/
protected PreviewUrlGeneratorManagerInterface $previewUrlGeneratorManager;

/**
* NextSettingsForm constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory service.
* @param \Drupal\next\Plugin\SitePreviewerManagerInterface $site_previewer_manager
* The site previewer manager.
* @param \Drupal\next\Plugin\PreviewUrlGeneratorManagerInterface $preview_url_generator_manager
* The preview url generator manager.
*/
public function __construct(ConfigFactoryInterface $config_factory, SitePreviewerManagerInterface $site_previewer_manager, PreviewUrlGeneratorManagerInterface $preview_url_generator_manager = NULL) {
if (!$preview_url_generator_manager) {
@trigger_error('Calling NextSettingsForm::__construct() without the $preview_url_generator_manager argument is deprecated in next:1.3.0 and will be required in next:2.0.0. See https://www.drupal.org/node/3308330', E_USER_DEPRECATED);
// @codingStandardsIgnoreStart
$preview_url_generator_manager = \Drupal::service('plugin.manager.next.preview_url_generator');
// @codingStandardsIgnoreEnd
}

parent::__construct($config_factory);
$this->sitePreviewerManager = $site_previewer_manager;
$this->previewUrlGeneratorManager = $preview_url_generator_manager;
}

/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('config.factory'), $container->get('plugin.manager.next.site_previewer'), $container->get('plugin.manager.next.preview_url_generator'));
$instance = parent::create($container);

$instance->sitePreviewerManager = $container->get('plugin.manager.next.site_previewer');
$instance->previewUrlGeneratorManager = $container->get('plugin.manager.next.preview_url_generator');

return $instance;
}

/**
Expand Down
18 changes: 14 additions & 4 deletions modules/next/src/NextSettingsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Drupal\next\Plugin\PreviewUrlGeneratorManagerInterface;
use Drupal\next\Plugin\SitePreviewerInterface;
use Drupal\next\Plugin\SitePreviewerManagerInterface;
use Psr\Log\LoggerInterface;

/**
* Provides a service for next settings.
Expand Down Expand Up @@ -36,6 +37,13 @@ class NextSettingsManager implements NextSettingsManagerInterface {
*/
protected PreviewUrlGeneratorManagerInterface $previewUrlGeneratorManager;

/**
* A logger instance.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;

/**
* NextSettingsManager constructor.
*
Expand All @@ -45,11 +53,14 @@ class NextSettingsManager implements NextSettingsManagerInterface {
* The site previewer plugin manager.
* @param \Drupal\next\Plugin\PreviewUrlGeneratorManagerInterface $preview_url_generator_manager
* The preview url generator plugin manager.
* @param \Psr\Log\LoggerInterface $logger
* The logger instance.
*/
public function __construct(ConfigFactoryInterface $config, SitePreviewerManagerInterface $site_previewer_manager, PreviewUrlGeneratorManagerInterface $preview_url_generator_manager) {
public function __construct(ConfigFactoryInterface $config, SitePreviewerManagerInterface $site_previewer_manager, PreviewUrlGeneratorManagerInterface $preview_url_generator_manager, LoggerInterface $logger) {
$this->config = $config;
$this->sitePreviewerManager = $site_previewer_manager;
$this->previewUrlGeneratorManager = $preview_url_generator_manager;
$this->logger = $logger;
}

/**
Expand Down Expand Up @@ -86,7 +97,7 @@ public function getSitePreviewer(): ?SitePreviewerInterface {
return $site_previewer;
}
catch (PluginException $exception) {
watchdog_exception('next_drupal', $exception);
$this->logger->error($exception->getMessage());

return NULL;
}
Expand All @@ -105,8 +116,7 @@ public function getPreviewUrlGenerator(): ?PreviewUrlGeneratorInterface {
return $preview_url_generator;
}
catch (PluginException $exception) {

watchdog_exception('next_drupal', $exception);
$this->logger->error($exception->getMessage());

return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/next/src/Plugin/Next/Revalidator/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function revalidate(EntityActionEvent $event): bool {
}
}
catch (\Exception $exception) {
watchdog_exception('next', $exception);
$this->logger->error($exception->getMessage());
$revalidated = FALSE;
}
}
Expand Down
5 changes: 3 additions & 2 deletions modules/next/src/Plugin/Next/SitePreviewer/Iframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ public function render(EntityInterface $entity, array $sites) {

// Handle revisions.
if ($entity instanceof RevisionableInterface && !$entity->isDefaultRevision()) {
/** @var \Drupal\Core\Entity\RevisionableInterface $revision */
$revision = $this->entityTypeManager->getStorage($entity->getEntityTypeId())->loadRevision($entity->getRevisionId());
/** @var \Drupal\Core\Entity\RevisionableStorageInterface $entity_storage */
$entity_storage = $this->entityTypeManager->getStorage($entity->getEntityTypeId());
$revision = $entity_storage->loadRevision($entity->getRevisionId());

$build['toolbar']['links']['#links']['status'] = [
'title' => $this->t('Revision: @date', [
Expand Down
3 changes: 1 addition & 2 deletions modules/next/tests/modules/next_tests/next_tests.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Next.js tests
description: Configures testing for Next.js
type: module
package: testing
core_version_requirement: ^8.8 || ^9
package: Testing
dependencies:
- next:next
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(LoggerChannelInterface $logger) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events[EntityEvents::ENTITY_ACTION] = ['onAction'];
return $events;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(LoggerChannelInterface $logger) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events[EntityEvents::ENTITY_REVALIDATED] = ['onRevalidated'];
return $events;
}
Expand Down
Loading

0 comments on commit b3e6c77

Please sign in to comment.