Problem/Motivation

After #3188474: Move the config_enforce form to an off-canvas dialog, we can refactor FormHelperTrait to simplify it.

This issue is only for Config Enforce, the Config Enforce Devel issue is: #3556975: Clean up/refactor DevelFormHelperTrait and ModalFormHelperTrait.

Proposed resolution

Delete unused code in 2.x, deprecate in 1.x.

Classes that will be refactored; likely to have methods deprecated in 1.x, deleted in 2.x

  • Drupal\config_enforce\Form\FormHelperTrait
    • Drupal\config_enforce_devel\Form\DevelFormHelperTrait (used by)
    • Drupal\config_enforce_devel\Form\ModalFormHelperTrait (used by)
Legend
  • ❌ = delete in 2.x, deprecate in 1.x
  • ❎ = delete usage
  • 🟢 = leave in place
  • ⬇️ = only one remaining usage, move to specific class
    • ➡️ = move method to this class
  • 💲 = refactor to use explicit parameters

Methods in FormHelperTrait and what to do with them:

  • 🟢 getFormId()
    • We could refactor each class inheriting from this to set a form ID manually, but that seems out of scope for this issue.
  • 🟢 setSharedFormProperties()
    • We should move away from this, but this is currently used all over the place so not part of this cleanup.
  • 🟢 form()
    • Same as above.
  • 🟢 formState()
    • Same as above.
  • ❌ addWarning()
  • 🟢 renderHtmlList()
    • 🟢 Drupal\config_enforce_devel\Form\EnforcedConfigs::updateEnforcedConfigs()
    • 🟢 Drupal\config_enforce_devel\Form\EnforcedConfigs::deleteEnforcedConfigs()
    • 🟢 Drupal\config_enforce_devel\Form\GenerateFormBase::getConfigsHtmlList()
    • 🟢 Drupal\config_enforce_devel\Form\GenerateFormBase::generateEnforcedConfigSettings()
  • ⬇️ getRowClasses()
    • ➡️ Drupal\config_enforce_devel\Form\EnforcedConfigs::getOptions()
  • ❌ setCurrentConfig()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::getEnforcedConfigsToCreate()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::getEnforcedConfigsToUpdate()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::getEnforcedConfigsToDelete()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::getConfigDependencies()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::getConfigDependencies()
    • ❎ Drupal\config_enforce_devel\Form\EnforcedConfigs::getOptions()
  • ❌ getCurrentConfig()
    • ⬇️ Drupal\config_enforce\Form\FormHelperTrait::getRowClasses()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::makeRegistryConfigsReadOnly()
    • ⬇️ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::isRegistryConfig()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::addEnforcedConfigEnabledField()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::overrideTargetModuleField()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::overrideConfigDirectoryField()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::overrideEnforcementLevelField()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::addEnforceDependenciesFields()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::disableEnforcedDependencies()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::setEnforcedConfigPathStates()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::currentConfigIsEnforced()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::getEnabledAttribute()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::getEnforceDependenciesAttribute()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::getEnforcedConfigValue()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::enforcedConfigValueExists()
    • ❌ Drupal\config_enforce_devel\Form\DevelFormHelperTrait::getConfigDependencies()
    • 💲 Drupal\config_enforce_devel\Form\EnforcedConfigs::getConfigNameLink()

Remaining tasks

  • Delete code
  • Test manually
  • Deprecate deleted code in 1.0.x branch

User interface changes

Should be none.

API changes

There will be removed classes, methods, etc. which we could mark as deprecated on the 1.0.x branch.

Data model changes

Should be none.

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

star-szr created an issue. See original summary.

star-szr’s picture

Issue summary: View changes

star-szr’s picture

Issue summary: View changes
star-szr’s picture

Issue summary: View changes
star-szr’s picture

Status: Active » Needs review

  • star-szr committed 23da4476 on 2.0.x
    [#3556977] refactor: Remove unused methods in FormHelperTrait
    

  • star-szr committed 332ae965 on 2.0.x
    [#3556977] refactor: Remove unused addWarning method
    
star-szr’s picture

Merged to 2.0.x, and I am going to mark this trait as internal in 2.0.x and 1.0.x rather than deprecating individual methods.

  • star-szr committed b8bf240d on 2.0.x
    [#3556977] docs: Mark FormHelperTrait as internal
    

  • star-szr committed 47a212c7 on 1.0.x
    [#3556977] docs: Mark FormHelperTrait as internal
    
star-szr’s picture

Status: Needs review » Fixed

Marked as internal on both branches, closing and will make a follow-up for further work.

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.

star-szr’s picture

Here is the follow-up issue: #3557733: Refactor out FormHelperTrait

Status: Fixed » Closed (fixed)

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