- π«π·France andypost
Nowadays idea of discovery
Requirement
objects could use attributes to define title, value and description.
Other similar kind of checks/tasks install system has, so approach from #50 sounds viable+++ b/core/lib/Drupal/Core/Render/Element/StatusReport.php @@ -35,13 +37,13 @@ public static function preRenderGroupRequirements($element) { $severities = static::getSeverities(); ... - $severity = $severities[REQUIREMENT_INFO]; + $severity = $severities[Requirements::SEVERITY_INFO]; ... - $severity = $severities[REQUIREMENT_OK]; + $severity = $severities[Requirements::SEVERITY_OK]; ... $grouped_requirements[$severity['status']]['title'] = $severity['title']; +++ b/core/lib/Drupal/Core/Requirements.php @@ -0,0 +1,30 @@ +final class Requirements {
it could be enum but it actually used only to group requirements
- πΊπ¦Ukraine voleger Ukraine, Rivne
Seems like we have an issue that already has some work done in that way π Add value objects to represent the return of hook_requirements Needs review
- First commit to issue fork.
- πΊπΈUnited States nicxvan
I am going to work on this because we need these constants for hook_update_requirements and hook_runtime_requirements.
The one downside is this approach is only available to core and not core modules/themes, or contrib or custom because they don't using composer to set up their autoloading. But I'm not sure that outweighs the advantages listed.
Since these classes are used in core, contrib, and custom, I think this disqualifies the constants.php approach.
However, we don't actually have to deprecate these here, I think we can do that when we deprecate hook_requirements, for now we can just create the new classes and just use them as we convert hooks.
- π«π·France andypost
Deprecation suppose removal of the usage, 240LOC surely needs chunking
git grep REQUIREMENT_ |wc -l
241 - πΊπΈUnited States nicxvan
Yes, I wouldn't create the deprecation here, just create the new landing place for constants and the new constants we need.
I wonder if there is a way to have both.
E,g. something like
/Drupal/Core/Constants
That is where the constants live, you can use it if you need it.
Maybe it makes sense to auto load it so they are available everywhere that uses autoloading. - πΊπΈUnited States nicxvan
I am not going to work on this, I think @berdir found a clean workaround, I think my comments about constants.php are still valid.