Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit db96746

Browse files
committed
Make new Application constructor arguments optional
Restores behavior to be backwards compatible; if the event manager, request, and/or response are not passed to the constructor, they are pulled from the service manager.
1 parent 8b49e87 commit db96746

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Application.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,22 @@ class Application implements
106106
*
107107
* @param mixed $configuration
108108
* @param ServiceManager $serviceManager
109+
* @param null|EventManagerInterface $events
110+
* @param null|RequestInterface $request
111+
* @param null|ResponseInterface $response
109112
*/
110113
public function __construct(
111114
$configuration,
112115
ServiceManager $serviceManager,
113-
EventManagerInterface $events,
114-
RequestInterface $request,
115-
ResponseInterface $response
116+
EventManagerInterface $events = null,
117+
RequestInterface $request = null,
118+
ResponseInterface $response = null
116119
) {
117120
$this->configuration = $configuration;
118121
$this->serviceManager = $serviceManager;
119-
$this->setEventManager($events);
120-
$this->request = $request;
121-
$this->response = $response;
122+
$this->setEventManager($events ?: $serviceManager->get('EventManager'));
123+
$this->request = $request ?: $serviceManager->get('Request');
124+
$this->response = $response ?: $serviceManager->get('Response');
122125
}
123126

124127
/**

0 commit comments

Comments
 (0)