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

Commit

Permalink
[zendframework/zendframework#4348] Fixed test errors
Browse files Browse the repository at this point in the history
- Only inject request if it is an HTTP request
- Allow injecting a null value for request in URI page type
  • Loading branch information
weierophinney committed May 22, 2013
1 parent 86e412d commit bd0af13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Page/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function getRequest()
* @param Request $request
* @return Fluent interface, returns self
*/
public function setRequest(Request $request)
public function setRequest(Request $request = null)
{
$this->request = $request;
return $this;
Expand All @@ -145,4 +145,4 @@ public function toArray()
)
);
}
}
}
9 changes: 7 additions & 2 deletions src/Service/AbstractNavigationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ protected function preparePages(ServiceLocatorInterface $serviceLocator, $pages)
$router = $application->getMvcEvent()->getRouter();
$request = $application->getMvcEvent()->getRequest();

// HTTP request is the only one that may be injected
if (!$request instanceof Request) {
$request = null;
}

return $this->injectComponents($pages, $routeMatch, $router, $request);
}

Expand Down Expand Up @@ -116,10 +121,10 @@ protected function getPagesFromConfig($config = null)
* @param array $pages
* @param RouteMatch $routeMatch
* @param Router $router
* @param Request $request
* @param null|Request $request
* @return mixed
*/
protected function injectComponents(array $pages, RouteMatch $routeMatch = null, Router $router = null, Request $request = null)
protected function injectComponents(array $pages, RouteMatch $routeMatch = null, Router $router = null, $request = null)
{
foreach ($pages as &$page) {
$hasUri = isset($page['uri']);
Expand Down

0 comments on commit bd0af13

Please sign in to comment.