Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'feature/bootstrapping-an-app-work' into develop

  • Loading branch information...
commit 3591de181c46ae73122d01b8e0d027dd3a072b46 2 parents 588f4bd + 1bec82d
@trq trq authored
View
4 lib/Proem/Bootstrap/Dispatch.php
@@ -59,7 +59,7 @@ public function in(AssetManagerInterface $assetManager)
new Event('proem.in.setup.dispatch'),
function ($responseEvent) use ($assetManager) {
// Check for a customized Dispatch\Dispatcher.
- if ($responseEvent->has('dispatcherAsset')) {
+ if ($responseEvent instanceof Event && $responseEvent->has('dispatcherAsset')) {
$assetManager->overrideAsSingleton('dispatcher', $responseEvent->get('dispatcherAsset'));
}
}
@@ -70,7 +70,7 @@ function ($responseEvent) use ($assetManager) {
new Event('proem.in.dispatch'),
function ($responseEvent) use ($assetManager) {
// Check for a customised dispatch handler.
- if ($responseEvent->has('dispatchHandler') && $responseEvent->get('dispatcherHandler') instanceof \Closure) {
+ if ($responseEvent instanceof Event && $responseEvent->has('dispatchHandler') && $responseEvent->get('dispatcherHandler') instanceof \Closure) {
$action = $responseEvent->get('dispatcherHandler');
$action($assetManager->resolve('request'));
} else {
View
2  lib/Proem/Bootstrap/Request.php
@@ -60,7 +60,7 @@ public function in(AssetManagerInterface $assetManager)
$assetManager->resolve('eventManager')->trigger(
new Event('proem.in.setup.request'),
function ($responseEvent) use ($assetManager) {
- if ($responseEvent->has('requestAsset')) {
+ if ($responseEvent instanceof Event && $responseEvent->has('requestAsset')) {
$assetManager->override('request', $responseEvent->get('requestAsset'));
}
}
View
2  lib/Proem/Bootstrap/Route.php
@@ -65,7 +65,7 @@ public function in(AssetManagerInterface $assetManager)
$assetManager->resolve('eventManager')->trigger(
new Event('proem.in.setup.route'),
function ($responseEvent) use ($assetManager) {
- if ($responseEvent->has('routeManagerAsset')) {
+ if ($responseEvent instanceof Event && $responseEvent->has('routeManagerAsset')) {
$assetManager->override('routeManager', $responseEvent->get('routeManagerAsset'));
}
}
View
13 lib/Proem/Proem.php
@@ -65,12 +65,13 @@ public function __construct(AssetManagerInterface $assetManager = null)
$this->assetManager = $assetManager;
}
- $this->assetManager->alias([
- 'Proem\Signal\EventManagerInterface' => 'Proem\Signal\EventManager',
- 'eventManager' => 'Proem\Signal\EventManagerInterface',
- 'Proem\Filter\ChainManagerInterface' => 'Proem\Filter\ChainManager',
- 'chainManager' => 'Proem\Filter\ChainManagerInterface'
- ]);
+ $this->assetManager->singleton(['eventManager' => '\Proem\Signal\EventManager']);
+ $this->assetManager->singleton(['chainManager' => '\Proem\Filter\ChainManager']);
+ }
+
+ public function getEventManager()
+ {
+ return $this->assetManager->resolve('eventManager');
}
/**
View
26 tests/ProemTest.php
@@ -35,14 +35,13 @@ public function testCanInstantiateProem()
{
$assetManager = m::mock('\Proem\Service\AssetManagerInterface');
$assetManager
- ->shouldReceive('alias')
+ ->shouldReceive('singleton')
->once()
- ->with([
- 'Proem\Signal\EventManagerInterface' => 'Proem\Signal\EventManager',
- 'eventManager' => 'Proem\Signal\EventManagerInterface',
- 'Proem\Filter\ChainManagerInterface' => 'Proem\Filter\ChainManager',
- 'chainManager' => 'Proem\Filter\ChainManagerInterface'
- ]);
+ ->with(['eventManager' => '\Proem\Signal\EventManager'])
+
+ ->shouldReceive('singleton')
+ ->once()
+ ->with(['chainManager' => '\Proem\Filter\ChainManager']);
$this->assertInstanceOf('Proem\Proem', new Proem($assetManager));
}
@@ -70,14 +69,13 @@ public function testLoadsDefaultEventManager()
$assetManager = m::mock('\Proem\Service\AssetManagerInterface');
$assetManager
- ->shouldReceive('alias')
+ ->shouldReceive('singleton')
+ ->once()
+ ->with(['eventManager' => '\Proem\Signal\EventManager'])
+
+ ->shouldReceive('singleton')
->once()
- ->with([
- 'Proem\Signal\EventManagerInterface' => 'Proem\Signal\EventManager',
- 'eventManager' => 'Proem\Signal\EventManagerInterface',
- 'Proem\Filter\ChainManagerInterface' => 'Proem\Filter\ChainManager',
- 'chainManager' => 'Proem\Filter\ChainManagerInterface'
- ])
+ ->with(['chainManager' => '\Proem\Filter\ChainManager'])
->shouldReceive('resolve')
->once()
Please sign in to comment.
Something went wrong with that request. Please try again.