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

Make TypeFactory injectable #83

Closed
6 tasks done
brotkrueml opened this issue Jan 20, 2022 · 0 comments
Closed
6 tasks done

Make TypeFactory injectable #83

brotkrueml opened this issue Jan 20, 2022 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation feature New feature or request
Milestone

Comments

@brotkrueml
Copy link
Owner

brotkrueml commented Jan 20, 2022

The TypeFactory has a static method createType() by now, which [creates the correct type model class. It was introduced to ease the creation of types independent from the namespace of that class and to avoid adjustments when a type is moved from pending to core section. But this approach has some drawbacks:

  • It is hard to test the classes which use this factory (for example, when using fixture types)
  • The factory cannot be overridden/injected (which is useful in some cases).
  • As the factory is not instantiated, dependencies (which may be needed some day) cannot be injected.

For these reasons the TypeFactory is adjusted:

  • The TypeFactory must be injected via DI. (This way the constructor arguments are not part of the API.)
  • It implements a non-static method create() which returns the given type (like the old createType static method).
  • The createType() method is marked as deprecated and triggers a deprecation notice on usage.
  • The examples in the documentation are adjusted.
  • The createType() method is listed in the deprecation chapter and will likely be removed in version 4.0.0.
  • A deprecation entry in the changelog is added.

This was inspired by a discussion in TYPO3 Slack.

@brotkrueml brotkrueml added documentation Improvements or additions to documentation feature New feature or request labels Jan 20, 2022
@brotkrueml brotkrueml self-assigned this Jan 20, 2022
@brotkrueml brotkrueml added this to the Version 3.0 milestone Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant