Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions quant.module
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use Drupal\quant\Plugin\QueueItem\RouteItem;
use Drupal\quant\QuantQueueFactory;
use Drupal\quant\Seed;
use Drupal\quant\Utility;
use Drupal\views\ViewExecutable;

/**
* Implements hook_menu_local_tasks_alter().
Expand Down Expand Up @@ -501,3 +502,16 @@ function quant_preprocess_views_view_table(&$variables) {
}
}
}

/**
* Implements hook_preprocess_views_view().
*/
function quant_preprocess_views_view(array &$variables) {
/** @var 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) on this page has exposed filters which need special handling for a static website.<br/> <a href="https://docs.quantcdn.io/integrations/drupal">Review the documentation for your options</a>.', ['@view_id' => $view->id()]));
}
}
2 changes: 1 addition & 1 deletion src/Controller/QuantNodeViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ 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 = NULL, ?EntityRepositoryInterface $entity_repository = NULL, 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
2 changes: 1 addition & 1 deletion src/Event/ConfigFormEventBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ConfigFormEventBase extends Event implements ConfigFormEventInterface {
/**
* {@inheritdoc}
*/
public function __construct(FormStateInterface $form_state = NULL) {
public function __construct(?FormStateInterface $form_state = NULL) {
$this->formState = $form_state;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Event/ConfigFormEventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface ConfigFormEventInterface {
* @param Drupal\Core\Form\FormStateInterface $form_state
* The configuration values.
*/
public function __construct(FormStateInterface $form_state = NULL);
public function __construct(?FormStateInterface $form_state = NULL);

/**
* Accessor for the form state.
Expand Down
2 changes: 1 addition & 1 deletion src/EventSubscriber/CollectionSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(EntityTypeManager $entity_type_manager, ConfigFactor
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events[QuantCollectionEvents::ENTITIES][] = ['collectEntities'];
$events[QuantCollectionEvents::TAXONOMY_TERMS][] = ['collectTaxonomyTerms'];
$events[QuantCollectionEvents::FILES][] = ['collectFiles'];
Expand Down
2 changes: 1 addition & 1 deletion src/EventSubscriber/NodeInsertSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function onNodeInsert(NodeInsertEvent $event) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events[NodeInsertEvent::NODE_INSERT_EVENT][] = ['onNodeInsert'];
return $events;
}
Expand Down
Loading
Loading