Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'feature/more-work-on-signals' into develop

  • Loading branch information...
commit cbe337b460362244b8c3e8839e5ca1e62a80b88e 2 parents 005e68c + 76e8cd1
Tony R Quilkey trq authored
18 lib/Proem/Bootstrap/Filter/Event/Dispatch.php
View
@@ -45,9 +45,10 @@ class Dispatch extends Event
/**
* Called prior to inBound.
*
- * A listener responding with an object implementing the
- * Proem\Dispatch\Template interface, will result in that object being
- * placed within the main service manager under the index of *dispatch*.
+ * A listener responding with an event containing a DI container holding an
+ * implemention of the Proem\Dispatch\Template interface, will result in
+ * that implementation being placed within the main service manager under
+ * the index of *dispatch*.
*
* @see Proem\Dispatch\Template
* @param Proem\Service\Manager\Template
@@ -59,8 +60,11 @@ public function preIn(Manager $assets)
$assets->get('events')->trigger(
(new Bootstrap('proem.pre.in.dispatch'))->setServiceManager($assets),
function ($response) use ($assets) {
- if ($response->provides('Proem\Dispatch\Template')) {
- $assets->set('dispatch', $response);
+ if (
+ $response->has('dispatch.asset') &&
+ $response->getParam('dispatch.asset')->provides('Proem\Dispatch\Template')
+ ) {
+ $assets->set('dispatch', $response->getParam('dispatch.asset'));
}
}
);
@@ -112,7 +116,9 @@ public function postIn(Manager $assets)
$assets->get('events')->trigger(
(new Bootstrap('proem.post.in.dispatch'))->setServiceManager($assets),
function ($response) use (&$skipDispatch) {
- $skipDispatch = true;
+ if ($response->has('skip.dispatch') && $response->getParam('skip.dispatch')) {
+ $skipDispatch = true;
+ }
}
);
}
14 lib/Proem/Bootstrap/Filter/Event/Request.php
View
@@ -44,9 +44,10 @@ class Request extends Event
/**
* Called prior to inBound.
*
- * A listener responding with an object that implements the
- * Proem\IO\Request\Template interface will result in that object
- * being placed within the service manager under the *request* index.
+ * A listener responding with an event containing a DI container holding an
+ * implemention of the Proem\IO\Request\Template interface, will result in
+ * that implementation being placed within the main service manager under
+ * the index of *request*.
*
* @param Proem\Service\Manager\Template $assets
* @triggers Proem\Bootstrap\Signal\Event\Bootstrap proem.pre.in.request
@@ -57,8 +58,11 @@ public function preIn(Manager $assets)
$assets->get('events')->trigger(
(new Bootstrap('proem.pre.in.request'))->setServiceManager($assets),
function ($response) use ($assets) {
- if ($response->provides('Proem\IO\Request\Template')) {
- $assets->set('request', $response);
+ if (
+ $response->has('request.asset') &&
+ $response->getParam('request.asset')->provides('Proem\IO\Request\Template')
+ ) {
+ $assets->set('request', $response->getParam('request.asset'));
}
}
);
13 lib/Proem/Bootstrap/Filter/Event/Response.php
View
@@ -44,9 +44,9 @@ class Response extends Event
/**
* Called prior to inBound.
*
- * A listener responding with an object implementing the
- * Proem\IO\Response\Template interface, will result in that
- * object being placed within the main service manager under
+ * A listener responding with an event containing a DI container holding an
+ * implemention of the Proem\IO\Response\Template interface, will result in
+ * that implementation being placed within the main service manager under
* the index of *response*.
*
* @param Proem\Service\Manager\Template $assets
@@ -58,8 +58,11 @@ public function preIn(Manager $assets)
$assets->get('events')->trigger(
(new Bootstrap('proem.pre.in.response'))->setServiceManager($assets),
function ($response) use ($assets) {
- if ($response->provides('Proem\IO\Response\Template')) {
- $assets->set('response', $response);
+ if (
+ $response->has('response.asset') &&
+ $response->getParam('response.asset')->provides('Proem\IO\Response\Template')
+ ) {
+ $assets->set('response', $response->getParam('response.asset'));
}
}
);
13 lib/Proem/Bootstrap/Filter/Event/Route.php
View
@@ -45,9 +45,9 @@ class Route extends Event
/**
* Called prior to inBound.
*
- * A listener responding with an object implementing the
- * Proem\Routing\Router\Template interface, will result in that
- * object being placed within the main service manager under
+ * A listener responding with an event containing a DI container holding an
+ * implemention of the Proem\Routing\Router\Template interface, will result in
+ * that implementation being placed within the main service manager under
* the index of *router*.
*
* @param Proem\Service\Manager\Template $assets
@@ -59,8 +59,11 @@ public function preIn(Manager $assets)
$assets->get('events')->trigger(
(new Bootstrap('proem.pre.in.router'))->setServiceManager($assets),
function ($response) use ($assets) {
- if ($response->provides('Proem\Routing\Router\Template')) {
- $assets->set('router', $response);
+ if (
+ $response->has('router.asset') &&
+ $response->getParam('router.asset')->provides('Proem\Routing\Router\Template')
+ ) {
+ $assets->set('router', $response->getParam('router.asset'));
}
}
);
13 lib/Proem/Dispatch/Stage.php
View
@@ -131,8 +131,8 @@ protected function processRoutes()
while ($payload = $router->route()) {
$assets->get('events')->trigger(
(new RouteMatch('proem.route.match'))->setPayload($payload),
- function ($e) use (&$dispatched, &$assets) {
- if ($e) {
+ function ($response) use (&$dispatched, &$assets) {
+ if ($response->has('isDispatchable') && $response->getParam('isDispatchable')) {
$dispatched = true;
$assets->get('events')->trigger(new RouteDispatch('proem.route.dispatch'));
}
@@ -168,12 +168,13 @@ public function dispatch($e)
* @param Proem\Routing\Signal\Event\RouteMatch $e
* @return bool
*/
- public function testRoute($e)
+ public function testRoute($event)
{
if ($this->assets->has('dispatch')) {
- return $this->assets->get('dispatch')
- ->setPayload($e->getPayload())
- ->isDispatchable();
+ return $event->setParam(
+ 'isDispatchable',
+ $this->assets->get('dispatch')->setPayload($event->getPayload())->isDispatchable()
+ );
}
}
4 lib/Proem/Dispatch/Standard.php
View
@@ -154,8 +154,8 @@ public function attachControllerMap($map)
*/
public function isDispatchable()
{
- $this->module = $this->payload->has('module') ? $this->prepare($this->payload->get('module') : '';
- $this->controller = $this->payload->has('controller') ? $this->prepare($this->payload->get('controller') : '';
+ $this->module = $this->payload->has('module') ? $this->prepare($this->payload->get('module')) : '';
+ $this->controller = $this->payload->has('controller') ? $this->prepare($this->payload->get('controller')) : '';
$this->action = $this->payload->has('action') ? $this->payload->get('action') : '';
foreach (array_reverse($this->controllerMaps) as $map) {
4 lib/Proem/IO/Response/Http/Standard.php
View
@@ -294,14 +294,14 @@ public function getContentLength()
*
* @param bool $include_content_length Optionaly disable the Content-Length header.
*/
- public function sendHeaders($include_content_length = true)
+ public function sendHeaders($include_content_length = false)
{
if (headers_sent()) {
return;
}
if ($include_content_length) {
- $this->headers->set('Content-Length', $this->length);
+ //$this->headers->set('Content-Length', $this->length);
}
if (in_array($this->httpStatus, [204, 304])) {
7 lib/Proem/Proem.php
View
@@ -184,8 +184,11 @@ public function init($environment = null)
$this->events->get()->trigger(
(new Bootstrap('proem.init'))->setServiceManager($this->serviceManager)->setEnvironment($environment),
function ($response) {
- if ($response instanceof Proem\Filter\Manager\Template) {
- $this->filterManager = $response;
+ if (
+ $response->has('filterManager.asset') &&
+ $response->getParam('filterManager.asset')->provides('Proem\Filter\Manager\Template')
+ ) {
+ $this->filterManager = $response->getParam('filterManager.asset');
}
}
);
10 lib/Proem/Signal/Event/Standard.php
View
@@ -132,6 +132,16 @@ public function getParam($index, $default = null)
}
/**
+ * Check for the existance of a parameter.
+ *
+ * @return bool
+ */
+ public function has($index)
+ {
+ return isset($this->params[$index]);
+ }
+
+ /**
* Set params
*
* @param array $params
7 lib/Proem/Signal/Event/Template.php
View
@@ -76,6 +76,13 @@ public function setParam($key, $param);
public function getParam($key, $default);
/**
+ * Check for the existance of a parameter.
+ *
+ * @return bool
+ */
+ public function has($index);
+
+ /**
* Set params
*
* @param array $params
Please sign in to comment.
Something went wrong with that request. Please try again.