Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Refactor \Drupal\og_ui\BundleFormAlter #734

Merged
merged 21 commits into from
Jul 19, 2024
Merged

Conversation

pfrenssen
Copy link
Contributor

@pfrenssen pfrenssen commented Dec 18, 2021

The \Drupal\og_ui\BundleFormAlter class is in need of refactoring and bug fixing.

In #733 new scalar type hints are being introduced, and the testing of this has uncovered that the BundleFormAlter class is calling into Og::isGroup() with the $bundle_id set to NULL, while this method is only accepting strings.

Apart from this bug the class is also showing its age and is not up to date with current best practices. Let's:

  • Look into the architecture of the class. Now it is using a very workaround way of instantiating it with an entity with is derived from the form state, then later on the form and form state are passed and a protected ::prepare() method then acts as a second constructor which populates further properties. Internally then the form and form state are still passed on between methods. It looks like this can be simplified a lot, by just passing on the form and form state and using some basic helper methods. It looks like the whole class can operate without keeping any state, with purely static methods.
  • Introduce strict typing and type hints wherever possible.
  • Rename variables so that their purpose is clear and non-ambiguous.
  • Update tests, especially the AJAX functionality is not being tested in a proper way.

@pfrenssen
Copy link
Contributor Author

After spending some quality time with the class I am realizing it would better be converted into a service, since it depends on a bunch of other services such as the GroupTypeManager.

@pfrenssen pfrenssen self-assigned this Dec 19, 2021
@pfrenssen
Copy link
Contributor Author

This is ready but blocked by #732. Assigning to me to keep track.

@pfrenssen
Copy link
Contributor Author

Now that #732 has been merged, this is unblocked and ready for review. Unassigning.

@pfrenssen pfrenssen removed their assignment Jan 13, 2022
@amitaibu amitaibu requested a review from bboro July 11, 2024 17:59
@amitaibu
Copy link
Member

@bboro if you can re-roll as-well please

@amitaibu
Copy link
Member

@bboro Thanks. I see Travis is failing - let's fix that first?

@bboro
Copy link
Contributor

bboro commented Jul 18, 2024

@amitaibu did phpcs ever work on this project?

@amitaibu
Copy link
Member

Yes - for example this PR

@bboro bboro merged commit c6a95aa into 8.x-1.x Jul 19, 2024
2 checks passed
@bboro bboro deleted the bundleformalter-wrong-type branch July 19, 2024 14:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants