Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b3fb7ac
Automated Project Update Bot fixes from run 11-199781.
Jun 18, 2024
1152997
Revert mock changes and use onlyMethods.
kepol Nov 22, 2024
733c472
Bump version to 10 and 11 and drop 9.
kepol Nov 22, 2024
6873619
Remove ContainerAwareEventDispatcher deprecation.
kepol Nov 22, 2024
975f449
Bumping to min 10.3 due to deprecations.
kepol Nov 22, 2024
dbcf41f
Merge branch '1.x' into project-update-bot-only
kepol Nov 22, 2024
7e0804a
Only support D11 for new branch.
kepol Jan 12, 2025
45255a6
Add "use" for classes.
kepol Jan 28, 2025
a7d08c6
Switch to Drupal 11 image.
kepol Jan 28, 2025
475eb79
Update params to be nullable.
kepol Jan 28, 2025
0862a69
Use generic database name.
kepol Jan 28, 2025
e3ff05c
Merge pull request #241 from quantcdn/feature/namespaced-classes
kepol Jan 28, 2025
dd6a43e
Merge branch 'feature/iframe-urls' into 2.x
kepol Jan 28, 2025
d988eb2
Merge branch 'feature/media-unpublish' into 2.x
kepol Jan 29, 2025
f6e6b7c
Add warning if view has exposed filters.
kepol Jan 29, 2025
230286f
Merge branch 'feature/multilingual-home-paths' into 2.x
kepol Jan 29, 2025
4346e1d
Updated warning text.
kepol Jan 29, 2025
9f22756
Fix linting.
kepol Jan 29, 2025
ee07f01
Merge pull request #243 from quantcdn/feature/views-exposed-filter-wa…
kepol Jan 29, 2025
87208ce
Fix deprecation error for constructor.
kepol Jan 29, 2025
7920ac4
Merge pull request #244 from quantcdn/feature/deprecation-constructor
kepol Jan 29, 2025
4a63502
Updated warning text.
kepol Jan 29, 2025
1d4b304
Fix lint error.
kepol Jan 31, 2025
f661292
Linting.
kepol Jan 31, 2025
7c9f6d4
Merge pull request #245 from quantcdn/feature/warning-text-fix
kepol Jan 31, 2025
4cbd423
Add a warning if a webform is on the page.
kepol Jan 31, 2025
6ac1d7b
Only show warning to admins.
kepol Jan 31, 2025
fd296b0
Merge pull request #246 from quantcdn/feature/webform-warning
kepol Jan 31, 2025
359541a
Add autoconfigure to services yml.
kepol Mar 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# To add new Drupal versions, update quant-ci-images repo.
name: Test and code coverage
on:
- push
jobs:
lint:
runs-on: ubuntu-latest
container: quantcdn/drupal-ci:9.4.x-dev
container: quantcdn/drupal-ci:11.0.x-dev
steps:
- uses: actions/checkout@v2
- name: Lint
run: phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,yml .

phpunit:
runs-on: ubuntu-latest
container: quantcdn/drupal-ci:9.4.x-dev
container: quantcdn/drupal-ci:11.0.x-dev

services:
mariadb:
image: mariadb:10.11
ports:
- 3306:3306
env:
MYSQL_DATABASE: drupal9
MYSQL_DATABASE: drupal
MYSQL_ROOT_PASSWORD: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
Expand All @@ -32,7 +33,7 @@ jobs:

steps:
- name: Install Drupal
run: drush si --db-url=mysql://root:drupal@mariadb:3306/drupal9 -y
run: drush si --db-url=mysql://root:drupal@mariadb:3306/drupal -y
working-directory: /var/www/drupal

- name: Install module dependencies
Expand Down
2 changes: 1 addition & 1 deletion modules/quant_api/quant_api.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Connect to the hosted Quant service
package: Quant

type: module
core_version_requirement: ^9.3 || ^10
core_version_requirement: ^11
configure: quant_api.settings_form
dependencies:
- drupal:quant
2 changes: 1 addition & 1 deletion modules/quant_api/src/Client/QuantClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public function sendRedirect(array $data) : array {
/**
* {@inheritdoc}
*/
public function sendFile(string $file, string $url, int $rid = NULL) : array {
public function sendFile(string $file, string $url, ?int $rid = NULL) : array {

// Ensure the file is accessible before attempting to send to the API.
if (!file_exists($file) || !is_readable($file) || !is_file($file)) {
Expand Down
2 changes: 1 addition & 1 deletion modules/quant_api/src/Client/QuantClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function send(array $data) : array;
* @throws \Drupal\quant_api\Exception\InvalidPayload
* @throws \Drupal\quant_api\Exception\InvalidResposne
*/
public function sendFile(string $file, string $url, int $rid = NULL) : array;
public function sendFile(string $file, string $url, ?int $rid = NULL) : array;

/**
* Send a redirect to the API.
Expand Down
10 changes: 5 additions & 5 deletions modules/quant_api/src/EventSubscriber/QuantApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Drupal\quant_api\EventSubscriber;

use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\quant\Event\QuantEvent;
use Drupal\quant\Event\QuantFileEvent;
Expand All @@ -14,6 +13,7 @@
use Drupal\quant\Utility;
use Drupal\quant_api\Client\QuantClientInterface;
use Drupal\quant_api\Exception\InvalidPayload;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
Expand All @@ -38,7 +38,7 @@ class QuantApi implements EventSubscriberInterface {
/**
* The event dispatcher.
*
* @var \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher
* @var \Symfony\Component\EventDispatcher\EventDispatcher
*/
protected $eventDispatcher;

Expand All @@ -52,10 +52,10 @@ class QuantApi implements EventSubscriberInterface {
* The Drupal HTTP Client to make requests.
* @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
* The logger channel factory.
* @param \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $event_dispatcher
* @param \Symfony\Component\EventDispatcher\EventDispatcher $event_dispatcher
* The event dispatcher.
*/
public function __construct(QuantClientInterface $client, LoggerChannelFactoryInterface $logger_factory, ContainerAwareEventDispatcher $event_dispatcher) {
public function __construct(QuantClientInterface $client, LoggerChannelFactoryInterface $logger_factory, EventDispatcher $event_dispatcher) {
$this->client = $client;
$this->logger = $logger_factory->get('quant_api');
$this->eventDispatcher = $event_dispatcher;
Expand All @@ -64,7 +64,7 @@ public function __construct(QuantClientInterface $client, LoggerChannelFactoryIn
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events[QuantEvent::OUTPUT] = ['onOutput', -999];
$events[QuantFileEvent::OUTPUT] = ['onMedia', -999];
$events[QuantRedirectEvent::UPDATE] = ['onRedirect', -999];
Expand Down
16 changes: 7 additions & 9 deletions modules/quant_api/tests/src/Unit/QuantClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace Drupal\Tests\quant_api\Unit;

use Drupal\Tests\UnitTestCase;
use Drupal\quant_api\Client\QuantClient;
use GuzzleHttp\Client;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\quant_api\Client\QuantClient;
use Drupal\quant_api\Exception\InvalidPayload;
use Drupal\Tests\UnitTestCase;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\RequestOptions;
Expand Down Expand Up @@ -199,10 +200,9 @@ public function testSendValid() {

/**
* Ensure that send handles server errors.
*
* @expectedException GuzzleHttp\Exception\RequestException
*/
public function testSendError() {
$this->expectException(RequestException::class);
$http = $this->prophesize(Client::class);
$logger = $this->prophesize(LoggerChannelFactoryInterface::class);
$config = $this->getConfigStub();
Expand Down Expand Up @@ -254,10 +254,9 @@ public function testSendRedirectValid() {

/**
* Ensure a valid redirect response is sent.
*
* @expectedException GuzzleHttp\Exception\RequestException
*/
public function testSendRedirectError() {
$this->expectException(RequestException::class);
$http = $this->prophesize(Client::class);
$logger = $this->prophesize(LoggerChannelFactoryInterface::class);
$config = $this->getConfigStub();
Expand All @@ -278,10 +277,9 @@ public function testSendRedirectError() {

/**
* Ensure files are validated before sending.
*
* @expectedException Drupal\quant_api\Exception\InvalidPayload
*/
public function testSendFileFileNoExist() {
$this->expectException(InvalidPayload::class);
// phpcs:ignore
global $exists_return;
// phpcs:ignore
Expand Down
2 changes: 1 addition & 1 deletion modules/quant_cron/quant_cron.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Run Quant tasks during cron
package: Quant

type: module
core_version_requirement: ^9.3 || ^10
core_version_requirement: ^11
configure: quant_cron.settings_form
dependencies:
- quant:quant_api
2 changes: 1 addition & 1 deletion modules/quant_purger/quant_purger.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Cache tag purger for Quant.
package: Quant

type: module
core_version_requirement: ^9.3 || ^10
core_version_requirement: ^11

dependencies:
- quant:quant
Expand Down
2 changes: 1 addition & 1 deletion modules/quant_purger/src/StackMiddleware/UrlRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(HttpKernelInterface $http_kernel, TrafficRegistryInt
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) {
$response = $this->httpKernel->handle($request, $type, $catch);
if ($this->determine($request, $response)) {
$this->registry->add(
Expand Down
2 changes: 1 addition & 1 deletion modules/quant_search/quant_search.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: 'Allows creation of Quant Search pages.'
package: Quant

type: module
core_version_requirement: ^9.3 || ^10
core_version_requirement: ^11
configure: quant_search.main
dependencies:
- drupal:quant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Drupal\quant_search\EventSubscriber;

use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\quant\Event\QuantEvent;
use Drupal\quant_search\Controller\Search;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
Expand All @@ -23,7 +23,7 @@ class SearchEventSubscriber implements EventSubscriberInterface {
/**
* The event dispatcher.
*
* @var \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher
* @var \Symfony\Component\EventDispatcher\EventDispatcher
*/
protected $eventDispatcher;

Expand All @@ -34,18 +34,18 @@ class SearchEventSubscriber implements EventSubscriberInterface {
*
* @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
* The logger channel factory.
* @param \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $event_dispatcher
* @param \Symfony\Component\EventDispatcher\EventDispatcher $event_dispatcher
* The event dispatcher.
*/
public function __construct(LoggerChannelFactoryInterface $logger_factory, ContainerAwareEventDispatcher $event_dispatcher) {
public function __construct(LoggerChannelFactoryInterface $logger_factory, EventDispatcher $event_dispatcher) {
$this->logger = $logger_factory->get('quant_search');
$this->eventDispatcher = $event_dispatcher;
}

/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events[QuantEvent::OUTPUT] = ['onOutput', 1];
return $events;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/quant_search/src/Form/ConfirmIndexClearForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ConfirmIndexClearForm extends ConfirmFormBase {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, string $id = NULL) {
public function buildForm(array $form, FormStateInterface $form_state, ?string $id = NULL) {
return parent::buildForm($form, $form_state);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/quant_sitemap/quant_sitemap.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Quant simple_sitemap support
package: Quant

type: module
core_version_requirement: ^9.3 || ^10
core_version_requirement: ^11

dependencies:
- quant:quant_api
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(SitemapManager $manager) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events[QuantCollectionEvents::ROUTES][] = ['collectRoutes'];
return $events;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/quant_sitemap/tests/src/Unit/SitemapManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function testSitemapUnavailable() {
$entity_manager_mock,
$module_list_mock,
])
->setMethods(['isAvailable'])
->onlyMethods(['isAvailable'])
->getMock();

$manager->expects($this->once())
Expand Down Expand Up @@ -197,7 +197,7 @@ public function testSimpleSitemapListItems() {
$entity_manager_mock,
$module_list_mock,
])
->setMethods(['isAvailable', 'getSitemapManager'])
->onlyMethods(['isAvailable', 'getSitemapManager'])
->getMock();

$manager->expects($this->once())
Expand Down
2 changes: 1 addition & 1 deletion modules/quant_tome/quant_tome.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: 'Deploy Tome static output to Quant.'
package: Quant

type: module
core_version_requirement: ^9.3 || ^10
core_version_requirement: ^11

dependencies:
- tome:tome_static
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function onResponse(ResponseEvent $event) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events[KernelEvents::RESPONSE][] = ['onResponse'];
return $events;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/quant_webform/quant_webform.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Quant Form support for Webform
package: Quant

type: module
core_version_requirement: ^9.3 || ^10
core_version_requirement: ^11

dependencies:
- quant:quant
Expand Down
2 changes: 1 addition & 1 deletion quant.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Quant content export
package: Quant

type: module
core_version_requirement: ^9.3 || ^10
core_version_requirement: ^11
configure: quant.config
dependencies:
- drupal:taxonomy
Expand Down
43 changes: 43 additions & 0 deletions quant.module
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
Expand Down Expand Up @@ -501,3 +502,45 @@ function quant_preprocess_views_view_table(&$variables) {
}
}
}

/**
* Implements hook_preprocess_views_view().
*/
function quant_preprocess_views_view(array &$variables) {
/** @var \Drupal\views\ViewExecutable $view */
$view = $variables['view'];

// If the view has exposed filters, add a warning for admins.
if ($view->exposed_data && \Drupal::currentUser()->hasRole('administrator')) {
\Drupal::messenger()->addWarning(t('The view (@view_id - @view_display) has exposed filters which need special handling for a static website.<br/> <a href="https://docs.quantcdn.io/integrations/drupal">See the documentation for your options</a>.',
[
'@view_id' => $view->id(),
'@view_display' => $view->current_display,
])
);
}

}

/**
* Implements hook_node_view().
*/
function quant_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {

// If there are any webforms in layout_builder, add warning for admins.
if ($node->hasField('layout_builder__layout') && !$node->get('layout_builder__layout')->isEmpty() && \Drupal::currentUser()->hasRole('administrator')) {
$sections = $node->get('layout_builder__layout')->getSections();

foreach ($sections as $section) {
$components = $section->getComponents();

foreach ($components as $component) {
$configuration = $component->get('configuration');
if (isset($configuration['webform_id'])) {
\Drupal::messenger()->addWarning(t('Forms need special handling for a static website. <a href="https://docs.quantcdn.io/integrations/drupal">See the documentation for your options</a>.'));
return;
}
}
}
}
}
3 changes: 3 additions & 0 deletions quant.services.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
services:
_defaults:
autoconfigure: true

plugin.manager.quant.metadata:
class: Drupal\quant\Plugin\QuantMetadataManager
parent: default_plugin_manager
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/QuantNodeViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class QuantNodeViewController extends NodeViewController {
* @param \Drupal\Core\Session\AccountSwitcherInterface $account_switcher
* The account switcher interface.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer, AccountInterface $current_user = NULL, EntityRepositoryInterface $entity_repository = NULL, RequestStack $request_stack, CurrentRouteMatch $route_match, AccountSwitcherInterface $account_switcher) {
public function __construct(EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer, AccountInterface $current_user, EntityRepositoryInterface $entity_repository, RequestStack $request_stack, CurrentRouteMatch $route_match, AccountSwitcherInterface $account_switcher) {

parent::__construct($entity_type_manager, $renderer, $current_user, $entity_repository);

$this->accountSwitcher = $account_switcher;
Expand Down
Loading