-
Notifications
You must be signed in to change notification settings - Fork 13
Adds factories for all middleware and a ConfigProvider #50
Adds factories for all middleware and a ConfigProvider #50
Conversation
We have a lot of middleware at this point, so they need to be moved to a subnamespace.
A number of factories depend on "virtual" services: responses, stream factories, etc. To define these services, I have created namespaced constants that define each, and provide documentation for what they represent. The individual factories then refer to these, and raise exceptions if they are missing. All middleware defined by this package now have factories present.
Defines a `ConfigProvider` class that registers factory entries for all provided middleware, and adds it to the package definition.
Interesting solution to use the constants file. I thought you would use constants in the factories but this is a better solution. I only find the uppercase names ugly. But as they are constants you should, otherwise you still have confusion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
|
||
public function getDependencies() : array | ||
{ | ||
// @codingStandardsIgnoreStart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Are lines too long?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. :)
Yeah, I prototyped originally with constants in the factories, and realized that was a poor solution when NOT using those factories. The PSR-1/2 and PSR-12 guides require constants be all-caps, underscore_separated, so I went with that style, and the values... well, seems like having them be equivalent to the constant name made as much sense as anything. I was happy with the end-result, particularly as these will essentially be inlined in the autoloader in production. |
Combines it with the entries for zendframework#47 and zendframework#50.
This patch accomplishes three things:
Zend\Expressive\Router\Middleware
. This is done due to the large number of middleware now provided (six!), and the fact that each will have a factory.ConfigProvider
class that defines factory entries for each middleware, and registers the provider in the package.