The OpenAgenda module has been refactored to allow for easier mocking of the PHP OpenAgenda SDK. This was achieved by moving the SDK instantiation into a dedicated service and updating all dependent components to use dependency injection.

Key Improvements

  • Decoupling: The module no longer directly instantiates the OpenAgendaSdk class in multiple places.
  • Testability: Developers can now mock the SDK by overriding the openagenda.sdk service, which is essential for unit and functional testing without making real API calls.
  • Best Practices: The refactoring aligns the module with Drupal's service-oriented architecture and dependency injection patterns.

Technical Changes

  1. Introduced openagenda.sdk service: A new service has been defined in openagenda.services.yml.
  2. Added OpenagendaSdkFactory: A factory class responsible for creating the SDK instance using the public key from the module's configuration.
  3. Refactored for Dependency Injection: Updated the following components to receive the SDK service via their constructors:
    • OpenagendaConnector
    • OpenagendaController
    • OpenagendaAdditionalFieldFilterBlock
    • OpenagendaPermissionValidator

Issue fork openagenda-3567472

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review
mably’s picture

Issue summary: View changes
mably’s picture

Version: 3.4.x-dev » 4.x-dev

  • mably committed dd10778e on 4.x
    task: #3567472 Refactor OpenAgenda SDK integration to use services and...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.