Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to implement a specific logic when a capacity is enabled #18454

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

cedric-anne
Copy link
Member

Checklist before requesting a review

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.

Description

It is based on #18306 and replaces it. It fixes #18304.

The purpose of this PR is to add a CapacityInterface::onCapacityEnabled() method that can be used to define a logic that has to be call only at the moment a capacity is enabled. For instance, the loading of the default import rules has to be done only once.

I had to review a bit the custom assets/dropdowns definition handling to be able to reload a definition at runtime. This was already done in the tests with some kind of hacky code, but now it is done in a more proper way, and this is no longer necessary to use the reflection API to do this.

I also added a call to CapacityInterface::onCapacityDisabled() in the AssetDefinition::cleanDbOnPurge(). It is probably unecessary for the most common cases, but it permits to be sure that the cleaning logic implemented by each capacity is executed when a definition is removed.

@trasher
Copy link
Contributor

trasher commented Dec 3, 2024

Tests are failing :/

@cedric-anne
Copy link
Member Author

Tests are failing :/

It seems that registered autoloaders are not available on the test execution context. I had to register them on each test setup, see my last commit.

@trasher trasher merged commit d8a9111 into glpi-project:main Dec 4, 2024
9 checks passed
@cedric-anne cedric-anne deleted the 11.0/on-capacity-enabled branch December 4, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom asset definitions add noticeable request performance hit
4 participants