Implement Item Usage Check Before Deletion in Item Management System #679
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description
Overview
This pull request introduces enhancements to the item management functionality by integrating a new service to check item usage before deletion. The changes ensure that items currently in use within tests cannot be deleted, thereby preventing potential disruptions in test configurations.
Key Changes
Item Usage Check in Deletion Process:
actions/class.Items.php
to include a check usingItemUsageService
before allowing an item to be deleted. If an item is in use, an error is thrown, and the deletion is halted.Introduction of
ItemUsageService
:ItemUsageService
inmodels/classes/search/ItemUsageService.php
. This service utilizesSearchProxy
to determine if an item is currently used in any tests and retrieves associated test labels.Service Provider for Item Usage:
SearchServiceProvider
inmodels/classes/search/SearchServiceProvider.php
to registerItemUsageService
with the dependency injection container, ensuring it is available for use across the application.Manifest Update:
manifest.php
to include the newSearchServiceProvider
, ensuring the new service is properly registered and available.Integration in Item Service:
models/classes/class.ItemsService.php
to incorporate the usage check within the item deletion logic, enhancing the robustness of the item management process.Benefits
ItemUsageService
centralizes the logic for checking item usage, making it easier to maintain and extend in the future.Conclusion
These changes significantly enhance the reliability and integrity of the item management system by ensuring that items cannot be deleted if they are currently in use within tests. This update is crucial for maintaining consistent and error-free test environments.