Skip to content

Commit

Permalink
feat: UHF-XXXX: Fix failing tests by fixing dependency-related errors. (
Browse files Browse the repository at this point in the history
#1517)

* Refactor events to custom module to get installation to succeed
* Make some services use lazyloading with events service.
* Add update hook & make sure drush deploy is run 1st.
* PHPCS
* Try to clear caches after importing DB to no avail.
  • Loading branch information
jiisuominen authored Oct 23, 2024
1 parent a5f741a commit 4eca6e9
Show file tree
Hide file tree
Showing 24 changed files with 346 additions and 39 deletions.
5 changes: 3 additions & 2 deletions conf/cmi/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ module:
flysystem: 0
focal_point: 0
gin_toolbar: 0
grants_events: 0
grant_applications_content: 0
grant_applications_noscript: 0
grants_admin_applications: 0
grants_applicant_info: 0
grants_application_search: 0
grants_attachments: 0
grants_audit_log: 0
grants_budget_components: 0
grants_club_section: 0
Expand Down Expand Up @@ -218,9 +218,10 @@ module:
webform_translation_permissions: 0
webform_ui: 0
webform_views: 0
grants_handler: 1
grants_attachments: 1
menu_admin_per_menu: 1
pathauto: 1
grants_handler: 2
content_translation: 10
externalauth: 10
views: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\grants_attachments\AttachmentFixerService;
use Drupal\grants_events\EventsService;
use Drupal\grants_handler\ApplicationGetterService;
use Drupal\grants_handler\ApplicationHelpers;
use Drupal\grants_handler\EventsService;
use Drupal\grants_handler\Helpers;
use Drupal\grants_handler\MessageService;
use Drupal\helfi_atv\AtvDocument;
Expand Down Expand Up @@ -62,7 +62,7 @@ public static function create(ContainerInterface $container): self {
$container->get('database'),
$container->get('grants_handler.application_getter_service'),
$container->get('http_client'),
$container->get('grants_handler.events_service'),
$container->get('grants_events.events_service'),
$container->get('helfi_atv.atv_service'),
$container->get('grants_handler.message_service'),
$container->get('current_user'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ core_version_requirement: ^9 || ^10
dependencies:
- webform
- grants_metadata
- grants_handler
- grants_events

'interface translation project': grants_attachments
'interface translation server pattern': modules/custom/grants_attachments/translations/%language.po
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ services:
'@helfi_atv.atv_service',
'@grants_profile.service',
'@grants_metadata.atv_schema',
'@grants_handler.events_service',
'@helfi_audit_log.audit_log',
'@entity_type.manager',
'@grants_metadata.application_data_service'
]
calls:
- [ setEventsService, [ '@?grants_events.events_service' ] ]

grants_attachments.attachment_fixer_service:
class: Drupal\grants_attachments\AttachmentFixerService
Expand Down
22 changes: 18 additions & 4 deletions public/modules/custom/grants_attachments/src/AttachmentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\TempStore\TempStoreException;
use Drupal\grants_attachments\Plugin\WebformElement\GrantsAttachments;
use Drupal\grants_events\EventsService;
use Drupal\grants_handler\ApplicationHelpers;
use Drupal\grants_handler\DebuggableTrait;
use Drupal\grants_handler\EventException;
use Drupal\grants_handler\EventsService;
use Drupal\grants_handler\Helpers;
use Drupal\grants_metadata\ApplicationDataService;
use Drupal\grants_metadata\AtvSchema;
Expand Down Expand Up @@ -67,6 +67,13 @@ class AttachmentHandler {
*/
protected EntityStorageInterface $fileStorage;

/**
* Events service.
*
* @var \Drupal\grants_events\EventsService
*/
protected EventsService $eventService;

/**
* Constructs an AttachmentHandler object.
*
Expand All @@ -82,8 +89,6 @@ class AttachmentHandler {
* Profile service.
* @param \Drupal\grants_metadata\AtvSchema $atvSchema
* ATV schema.
* @param \Drupal\grants_handler\EventsService $eventService
* Events service.
* @param \Drupal\helfi_audit_log\AuditLogService $auditLogService
* Audit log mandate errors.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
Expand All @@ -101,7 +106,6 @@ public function __construct(
protected AtvService $atvService,
protected GrantsProfileService $grantsProfileService,
protected AtvSchema $atvSchema,
protected EventsService $eventService,
protected AuditLogService $auditLogService,
EntityTypeManagerInterface $entityTypeManager,
protected ApplicationDataService $applicationDataService,
Expand All @@ -113,6 +117,16 @@ public function __construct(
$this->setDebug(NULL);
}

/**
* Set the getter service.
*
* @param \Drupal\grants_events\EventsService $eventsService
* Events service.
*/
public function setEventsService(EventsService $eventsService): void {
$this->eventService = $eventsService;
}

/**
* Get file fields.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use Drupal\Core\Messenger\MessengerTrait;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\grants_attachments\Plugin\WebformElement\GrantsAttachments;
use Drupal\grants_events\EventsService;
use Drupal\grants_handler\ApplicationGetterService;
use Drupal\grants_handler\ApplicationStatusService;
use Drupal\grants_handler\ApplicationUploaderService;
use Drupal\grants_handler\EventsService;
use Drupal\grants_metadata\ApplicationDataService;
use Drupal\helfi_atv\AtvService;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand All @@ -34,7 +34,7 @@ class GrantsAttachmentsController extends ControllerBase {
* The helfi_atv service.
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
* Drupal requests.
* @param \Drupal\grants_handler\EventsService $eventsService
* @param \Drupal\grants_events\EventsService $eventsService
* Use submission events productively.
* @param \Drupal\grants_handler\ApplicationStatusService $applicationStatusService
* Application status service.
Expand Down Expand Up @@ -62,7 +62,7 @@ public static function create(ContainerInterface $container): static {
return new static(
$container->get('helfi_atv.atv_service'),
$container->get('request_stack'),
$container->get('grants_handler.events_service'),
$container->get('grants_events.events_service'),
$container->get('grants_handler.application_status_service'),
$container->get('grants_metadata.application_data_service'),
$container->get('grants_handler.application_getter_service'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\grants_attachments\AttachmentHandler;
use Drupal\grants_attachments\Element\GrantsAttachments as ElementGrantsAttachments;
use Drupal\grants_handler\EventsService;
use Drupal\grants_events\EventsService;
use Drupal\webform\Plugin\WebformElement\WebformCompositeBase;
use Drupal\webform\WebformSubmissionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down Expand Up @@ -79,7 +79,7 @@ final class GrantsAttachments extends WebformCompositeBase {
/**
* Events service.
*
* @var \Drupal\grants_handler\EventsService
* @var \Drupal\grants_events\EventsService
*/
protected EventsService $eventsService;

Expand All @@ -93,7 +93,7 @@ public static function create(
$plugin_definition,
): GrantsAttachments {
$instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
$instance->eventsService = $container->get('grants_handler.events_service');
$instance->eventsService = $container->get('grants_events.events_service');
return $instance;
}

Expand Down
5 changes: 5 additions & 0 deletions public/modules/custom/grants_events/grants_events.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'grants_events'
type: module
description: 'Handle application events'
package: helfi
core_version_requirement: ^10 || ^11
6 changes: 6 additions & 0 deletions public/modules/custom/grants_events/grants_events.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

/**
* @file
* Primary module hooks for grants_events module.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
grants_events.events_service:
class: Drupal\grants_events\EventsService
arguments: [ '@http_client', '@logger.factory' ]
10 changes: 10 additions & 0 deletions public/modules/custom/grants_events/src/EventException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Drupal\grants_events;

/**
* Exception for Event exceptions.
*/
class EventException extends \Exception {

}
Loading

0 comments on commit 4eca6e9

Please sign in to comment.