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:
[x] The TypeFactory must be injected via DI. (This way the constructor arguments are not part of the API.)
[x] It implements a non-static method create() which returns the given type (like the old createType static method).
[x] The createType() method is marked as deprecated and triggers a deprecation notice on usage.
[x] The examples in the documentation are adjusted.
[x] The createType() method is listed in the deprecation chapter and will likely be removed in version 4.0.0.
[x] A deprecation entry in the changelog is added.
The
TypeFactory
has a static methodcreateType()
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:For these reasons the TypeFactory is adjusted:
TypeFactory
must be injected via DI. (This way the constructor arguments are not part of the API.)create()
which returns the given type (like the oldcreateType
static method).createType()
method is marked as deprecated and triggers a deprecation notice on usage.createType()
method is listed in the deprecation chapter and will likely be removed in version 4.0.0.This was inspired by a discussion in TYPO3 Slack.