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

Commit ccee9b2

Browse files
committed
Merge branch 'hotfix/352'
Close #403 Fixes #352
2 parents 02c489b + a316ac9 commit ccee9b2

File tree

5 files changed

+43
-9
lines changed

5 files changed

+43
-9
lines changed

.docheader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
22
* @see https://github.com/zendframework/zend-expressive for the canonical source repository
3-
* @copyright Copyright (c) 2015-%year% Zend Technologies USA Inc. (http://www.zend.com)
3+
* @copyright Copyright (c) %regexp:(20\d{2}-)?%%year% Zend Technologies USA Inc. (http://www.zend.com)
44
* @license https://github.com/zendframework/zend-expressive/blob/master/LICENSE.md New BSD License
55
*/

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"zendframework/zend-expressive-fastroute": "^1.0",
3333
"zendframework/zend-expressive-zendrouter": "^1.0",
3434
"zendframework/zend-servicemanager": "^2.6",
35-
"malukenho/docheader": "^0.1.0"
35+
"malukenho/docheader": "^0.1.5"
3636
},
3737
"autoload": {
3838
"psr-4": {

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AppFactory.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,31 @@ final class AppFactory
4040
* @param null|Router\RouterInterface $router Router implementation to use;
4141
* defaults to the FastRoute router bridge.
4242
* @return Application
43+
* @throws Exception\MissingDependencyException if the container was not
44+
* provided and the ServiceManager class is not present.
45+
* @throws Exception\MissingDependencyException if the router was not
46+
* provided and the Router\FastRouteRouter class is not present.
4347
*/
4448
public static function create(
4549
ContainerInterface $container = null,
4650
Router\RouterInterface $router = null
4751
) {
52+
if (! $container && ! class_exists(ServiceManager::class)) {
53+
throw new Exception\MissingDependencyException(sprintf(
54+
'%s requires a container, but none was provided and %s is not installed',
55+
__CLASS__,
56+
ServiceManager::class
57+
));
58+
}
59+
60+
if (! $router && ! class_exists(Router\FastRouteRouter::class)) {
61+
throw new Exception\MissingDependencyException(sprintf(
62+
'%s requires a router, but none was provided and %s is not installed',
63+
__CLASS__,
64+
Router\FastRouteRouter::class
65+
));
66+
}
67+
4868
$container = $container ?: new ServiceManager();
4969
$router = $router ?: new Router\FastRouteRouter();
5070
$emitter = new Emitter\EmitterStack();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-expressive for the canonical source repository
4+
* @copyright Copyright (c) 2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-expressive/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace Zend\Expressive\Exception;
9+
10+
use RuntimeException;
11+
12+
class MissingDependencyException extends RuntimeException implements ExceptionInterface
13+
{
14+
}

0 commit comments

Comments
 (0)