You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
As of now, many factories apply decisions based on the context or parameters (not the configuration) of the application.
Some examples are the Zend\Mvc\Service\ViewManagerFactory or the Zend\Mvc\Service\RequestFactory, which use the Console::isConsole() to decide what to build.
In these particular cases, the problem is also made worse by the fact that we're using the global scope to modify how our applications work, but in many apps I also see things like following:
The problem in this particular case is that Something returned by this factory can't be reused after an application dispatch, as it is bound to one particular run of the app itself.
Suggested solution
Remove any contextual switches (in factories) that aren't related to configuration. As an example taken from the factories that I linked above, we can make the Request object non-shared, and the ViewManager could decide whether to act as Console or HTTP view manager at runtime.
Banning this approach from new code (as a code-style rule or such) would also be suggested.
Affected factories
Zend\Mvc\Service\ConsoleViewManagerFactory
Zend\Mvc\Service\RequestFactory
Zend\Mvc\Service\ResponseFactory
Zend\Mvc\Service\RouterFactory
Zend\Mvc\Service\ViewManagerFactory
Not sure about sessions right now, but we could also get rid of internal PHP sessions in order to be able to use different sessions across multiple requests, but that's a different story.
The text was updated successfully, but these errors were encountered:
Can you assign both of them to the 3.0 Milestone - it would be easier to find.
I'd suggest generating two separate configuration files for each context, even if it is just to swap out those contextual services (plus there is routes).
Strictly related to #5599
The Problem
As of now, many factories apply decisions based on the context or parameters (not the configuration) of the application.
Some examples are the
Zend\Mvc\Service\ViewManagerFactory
or theZend\Mvc\Service\RequestFactory
, which use theConsole::isConsole()
to decide what to build.In these particular cases, the problem is also made worse by the fact that we're using the global scope to modify how our applications work, but in many apps I also see things like following:
The problem in this particular case is that
Something
returned by this factory can't be reused after an application dispatch, as it is bound to one particular run of the app itself.Suggested solution
Remove any contextual switches (in factories) that aren't related to configuration. As an example taken from the factories that I linked above, we can make the
Request
object non-shared, and theViewManager
could decide whether to act asConsole
orHTTP
view manager at runtime.Banning this approach from new code (as a code-style rule or such) would also be suggested.
Affected factories
Zend\Mvc\Service\ConsoleViewManagerFactory
Zend\Mvc\Service\RequestFactory
Zend\Mvc\Service\ResponseFactory
Zend\Mvc\Service\RouterFactory
Zend\Mvc\Service\ViewManagerFactory
Not sure about sessions right now, but we could also get rid of internal PHP sessions in order to be able to use different sessions across multiple requests, but that's a different story.
The text was updated successfully, but these errors were encountered: