Skip to content
Browse files

Merge branch 'release-0.2.5'

  • Loading branch information...
2 parents f433944 + 215ef48 commit f7d88dbdf398b47f6f6be74a97877f3fe802f581 @trq trq committed
Showing with 887 additions and 263 deletions.
  1. +1 −0 .gitignore
  2. +61 −0 Phakefile
  3. +0 −14 bin/build
  4. +0 −36 bin/bump-version
  5. +0 −4 bin/runtests
  6. +19 −0 composer.json
  7. +8 −7 lib/Proem/Api/Bootstrap/Filter/Event/Dispatch.php
  8. +30 −9 lib/Proem/Api/Bootstrap/Filter/Event/Request.php
  9. +33 −10 lib/Proem/Api/Bootstrap/Filter/Event/Response.php
  10. +24 −9 lib/Proem/Api/Bootstrap/Filter/Event/Route.php
  11. +27 −2 lib/Proem/Api/Bootstrap/Signal/Event/Bootstrap.php
  12. +3 −2 lib/Proem/Api/Ext/Module/Generic.php
  13. +3 −2 lib/Proem/Api/Ext/Plugin/Generic.php
  14. +6 −6 lib/Proem/Api/Ext/{Generic.php → Template.php}
  15. +4 −3 lib/Proem/Api/Filter/Event/Generic.php
  16. +43 −0 lib/Proem/Api/Filter/Event/Template.php
  17. +7 −6 lib/Proem/Api/Filter/{Manager.php → Manager/Standard.php}
  18. +51 −0 lib/Proem/Api/Filter/Manager/Template.php
  19. +6 −5 lib/Proem/Api/IO/{Http/FakeRequest.php → Request/Http/Fake.php}
  20. +7 −6 lib/Proem/Api/IO/{Http/Request.php → Request/Http/Standard.php}
  21. +5 −16 bin/new-file → lib/Proem/Api/IO/Request/Template.php
  22. +6 −7 lib/Proem/Api/IO/{Http/Response.php → Response/Http/Standard.php}
  23. +44 −0 lib/Proem/Api/IO/Response/Template.php
  24. +40 −36 lib/Proem/Api/Proem.php
  25. +3 −2 lib/Proem/Api/Routing/Route/Generic.php
  26. +2 −1 lib/Proem/Api/Routing/Route/Standard.php
  27. +39 −0 lib/Proem/Api/Routing/Route/Template.php
  28. +5 −5 lib/Proem/Api/Routing/{Router.php → Router/Standard.php}
  29. +43 −0 lib/Proem/Api/Routing/Router/Template.php
  30. +4 −3 lib/Proem/Api/Service/Asset/{Generic.php → Standard.php}
  31. +55 −0 lib/Proem/Api/Service/Asset/Template.php
  32. +8 −7 lib/Proem/Api/Service/{Manager.php → Manager/Standard.php}
  33. +51 −0 lib/Proem/Api/Service/Manager/Template.php
  34. +15 −9 lib/Proem/Api/Signal/Event/{Generic.php → Standard.php}
  35. +52 −0 lib/Proem/Api/Signal/Event/Template.php
  36. +11 −10 lib/Proem/Api/Signal/{Manager.php → Manager/Standard.php}
  37. +41 −0 lib/Proem/Api/Signal/Manager/Template.php
  38. +3 −3 lib/Proem/Api/Util/Opt/Option.php
  39. +1 −0 phake
  40. +19 −0 tests/lib/Proem/Tests/Ext/Fixtures/MyApp/Module/Foo.php
  41. +64 −0 tests/lib/Proem/Tests/ExtTest.php
  42. +3 −3 tests/lib/Proem/Tests/FilterTest.php
  43. +2 −2 tests/lib/Proem/Tests/Fixtures/Proem/Ext/Plugin/Foo.php
  44. +1 −1 tests/lib/Proem/Tests/Fixtures/Proem/Service/Asset/Bar.php
  45. +1 −1 tests/lib/Proem/Tests/Fixtures/Proem/Service/Asset/Foo.php
  46. +7 −7 tests/lib/Proem/Tests/IO/Http/FakeRequestTest.php
  47. +2 −2 tests/lib/Proem/Tests/IO/Http/ResponseTest.php
  48. +7 −7 tests/lib/Proem/Tests/Routing/RouterTest.php
  49. +14 −14 tests/lib/Proem/Tests/ServiceTest.php
  50. +4 −4 tests/lib/Proem/Tests/SignalTest.php
  51. +2 −2 tests/lib/Proem/Tests/Util/OptTest.php
View
1 .gitignore
@@ -1 +1,2 @@
tests/log/*
+vendor
View
61 Phakefile
@@ -0,0 +1,61 @@
+<?php
+
+group('dev', function() {
+
+ desc('Run the unit tests');
+ task('tests', function($args) {
+ if (isset($args['verbose'])) {
+ system('phpunit --colors --debug --verbose --configuration tests/phpunit.xml');
+ } else {
+ system('phpunit --colors --configuration tests/phpunit.xml');
+ }
+ });
+
+ desc('Build the Phar archive');
+ task('build', 'tests', function($args) {
+ chdir('lib');
+ $phar = new Phar('proem.phar');
+ $phar->buildFromDirectory('.');
+ $phar->setStub("<?php
+ Phar::mapPhar('proem.phar');
+ require_once 'phar://proem.phar/Proem/Autoloader.php';
+ (new Proem\Autoloader())->registerNamespaces(['Proem' => 'phar://proem.phar'])->register();
+ __HALT_COMPILER();
+ ?>");
+ rename('proem.phar', '../build/proem.phar');
+ chdir('../');
+ if (isset($args['runtests'])) {
+ system('phpunit --colors tests/phar-test.php');
+ }
+ });
+
+ desc('Bump the version number');
+ task('bump', function($args) {
+ $file = file_get_contents('lib/Proem/Api/Proem.php');
+ preg_match('/VERSION = \'([0-9]?)\.([0-9]?)\.([a-z0-9])\';/', $file, $matches);
+ list($all, $major, $minor, $incr) = $matches;
+ if (isset($args['major'])) {
+ $major = (string) ++$major;
+ $minor = '0';
+ $incr = '0';
+ } elseif (isset($args['minor'])) {
+ $minor = (string) ++$minor;
+ $incr = '0';
+ } elseif (isset($args['incr'])) {
+ if ($args['incr'] === 'true') {
+ $incr = (string) ++$incr;
+ } else {
+ $incr = $args['incr'];
+ }
+ }
+ $version = "$major.$minor.$incr";
+ echo "VERSION = '$version'\n";
+ if (isset($args['write'])) {
+ $file = preg_replace('/VERSION = \'(.*)\';/', "VERSION = '$version';", $file);
+ file_put_contents('lib/Proem/Api/Proem.php', $file);
+ }
+ });
+
+});
+
+task('default', 'dev:tests');
View
14 bin/build
@@ -1,14 +0,0 @@
-#!/usr/bin/env php
-<?php
-chdir('lib');
-$phar = new Phar('proem.phar');
-$phar->buildFromDirectory('.');
-$phar->setStub("<?php
-Phar::mapPhar('proem.phar');
-require_once 'phar://proem.phar/Proem/Autoloader.php';
-(new Proem\Autoloader())->registerNamespaces(['Proem' => 'phar://proem.phar'])->register();
-__HALT_COMPILER();
-?>");
-rename('proem.phar', '../build/proem.phar');
-chdir('../');
-system('phpunit --colors tests/phar-test.php');
View
36 bin/bump-version
@@ -1,36 +0,0 @@
-#!/bin/bash
-
-option=$1;
-
-version=`grep 'VERSION' lib/Proem/Api/Proem.php`
-set -- $version
-
-IFS="'"; declare -a Array=($*)
-line="${Array[4]}"
-
-set -- $line
-
-IFS="."; declare -a Array=($*)
-major="${Array[0]}"
-minor="${Array[1]}"
-incr="${Array[2]}"
-
-if [ "$option" = "-major" ];
-then
- major=$((major+1))
- minor=0
- incr=0
-elif [ "$option" = "-minor" ]; then
- minor=$((minor+1))
- incr=0
-elif [ "$option" = "-incr" ]; then
- incr=$((incr+1))
-else
- echo "Usage: $0 -[major|minor|incr]";
- exit;
-fi
-
-echo "incremented to $major.$minor.$incr";
-
-sed "s/VERSION = '.*';/VERSION = '$major.$minor.$incr';/" lib/Proem/Api/Proem.php > lib/Proem/Api/Proem.php.new
-mv lib/Proem/Api/Proem.php.new lib/Proem/Api/Proem.php
View
4 bin/runtests
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-# phpunit --colors --debug --verbose --configuration tests/phpunit.xml
-phpunit --colors --configuration tests/phpunit.xml
View
19 composer.json
@@ -0,0 +1,19 @@
+{
+ "name": "proem/proem",
+ "description": "A lightweight, simple, fast MVC implementation for PHP5.4",
+ "keywords": ["MVC","Framework"],
+ "homepage": "http://proemframework.org",
+ "type": "library",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Tony R Quilkey",
+ "email": "trq@proemframework.org",
+ "homepage": "http://thorpesystems.com"
+ }
+ ],
+ "require": {
+ "php": ">=5.4.0",
+ "jaz303/phake": "dev-master"
+ }
+}
View
15 lib/Proem/Api/Bootstrap/Filter/Event/Dispatch.php
@@ -30,15 +30,16 @@
*/
namespace Proem\Api\Bootstrap\Filter\Event;
-use Proem\Service\Manager,
- Proem\Bootstrap\Signal\Event\Bootstrap;
+use Proem\Service\Manager\Template as Manager,
+ Proem\Bootstrap\Signal\Event\Bootstrap,
+ Proem\Filter\Event\Generic as Event;
/**
* Proem\Api\Bootstrap\Filter\Event\Dispatch
*
* The default "Dispatch" filter event.
*/
-class Dispatch extends \Proem\Filter\Event\Generic
+class Dispatch extends Event
{
/**
* preIn
@@ -47,7 +48,7 @@ class Dispatch extends \Proem\Filter\Event\Generic
*/
public function preIn(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'pre.in.dispatch',
'params' => [],
@@ -76,7 +77,7 @@ public function inBound(Manager $assets)
*/
public function postIn(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'post.in.dispatch',
'params' => [],
@@ -95,7 +96,7 @@ public function postIn(Manager $assets)
*/
public function preOut(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'pre.out.dispatch',
'params' => [],
@@ -124,7 +125,7 @@ public function outBound(Manager $assets)
*/
public function postOut(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'post.out.dispatch',
'params' => [],
View
39 lib/Proem/Api/Bootstrap/Filter/Event/Request.php
@@ -30,31 +30,42 @@
*/
namespace Proem\Api\Bootstrap\Filter\Event;
-use Proem\Service\Manager,
- Proem\Bootstrap\Signal\Event\Bootstrap;
+use Proem\Service\Manager\Template as Manager,
+ Proem\Bootstrap\Signal\Event\Bootstrap,
+ Proem\IO\Request\Http\Standard as HTTPRequest,
+ Proem\Service\Asset\Standard as Asset,
+ Proem\Filter\Event\Generic as Event;
/**
* Proem\Api\Bootstrap\Filter\Event\Request
*
* The default "Request" filter event.
*/
-class Request extends \Proem\Filter\Event\Generic
+class Request extends Event
{
/**
* preIn
*
* Called prior to inBound
+ *
+ * The preIn Filter event will trigger a pre.in.request Signal.
+ *
+ * If this Signal returns a Proem\IO\Http\Request object load it into the Asset Manager.
*/
public function preIn(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'pre.in.request',
'params' => [],
'target' => $this,
'method' => __FUNCTION__,
'event' => (new Bootstrap())->setServiceManager($assets),
- 'callback' => function($e) {},
+ 'callback' => function($e) use ($assets) {
+ if ($e->provides('Proem\IO\Request\Template')) {
+ $assets->set('request', $e);
+ }
+ },
]);
}
}
@@ -63,10 +74,20 @@ public function preIn(Manager $assets)
* inBound
*
* Method to be called on the way into the filter.
+ *
+ * Checks to see if we already have an Asset providing Proem\IO\Http\Request, if not, we provide one.
*/
public function inBound(Manager $assets)
{
-
+ if (!$assets->provides('Proem\IO\Request\Template')) {
+ $asset = new Asset;
+ $assets->set(
+ 'request',
+ $asset->set('Proem\IO\Request\Template', $asset->single(function() {
+ return new HTTPRequest;
+ }))
+ );
+ }
}
/**
@@ -76,7 +97,7 @@ public function inBound(Manager $assets)
*/
public function postIn(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'post.in.request',
'params' => [],
@@ -95,7 +116,7 @@ public function postIn(Manager $assets)
*/
public function preOut(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'pre.out.request',
'params' => [],
@@ -124,7 +145,7 @@ public function outBound(Manager $assets)
*/
public function postOut(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'post.out.request',
'params' => [],
View
43 lib/Proem/Api/Bootstrap/Filter/Event/Response.php
@@ -30,31 +30,42 @@
*/
namespace Proem\Api\Bootstrap\Filter\Event;
-use Proem\Service\Manager,
- Proem\Bootstrap\Signal\Event\Bootstrap;
+use Proem\Service\Manager\Template as Manager,
+ Proem\Bootstrap\Signal\Event\Bootstrap,
+ Proem\Service\Asset\Standard as Asset,
+ Proem\IO\Response\Http\Standard as HTTPResponse,
+ Proem\Filter\Event\Generic as Event;
/**
* Proem\Api\Bootstrap\Filter\Event\Response
*
* The default "Response" filter event.
*/
-class Response extends \Proem\Filter\Event\Generic
+class Response extends Event
{
/**
* preIn
*
* Called prior to inBound
+ *
+ * The preIn Filter event will trigger a pre.in.response Signal.
+ *
+ * If this Signal returns a Proem\IO\Http\Response object load it into the Asset Manager.
*/
public function preIn(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'pre.in.response',
'params' => [],
'target' => $this,
'method' => __FUNCTION__,
'event' => (new Bootstrap())->setServiceManager($assets),
- 'callback' => function($e) {},
+ 'callback' => function($e) use ($assets) {
+ if ($e->provides('Proem\IO\Response\Template')) {
+ $assets->set('response', $e);
+ }
+ },
]);
}
}
@@ -63,10 +74,20 @@ public function preIn(Manager $assets)
* inBound
*
* Method to be called on the way into the filter.
+ *
+ * Checks to see if we already have an Asset providing Proem\IO\Http\Response, if not, we provide one.
*/
public function inBound(Manager $assets)
{
-
+ if (!$assets->provides('Proem\IO\Response\Template')) {
+ $asset = new Asset;
+ $assets->set(
+ 'response',
+ $asset->set('Proem\IO\Response\Template', $asset->single(function() {
+ return new HTTPResponse;
+ }))
+ );
+ }
}
/**
@@ -76,7 +97,7 @@ public function inBound(Manager $assets)
*/
public function postIn(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'post.in.response',
'params' => [],
@@ -95,7 +116,7 @@ public function postIn(Manager $assets)
*/
public function preOut(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'pre.out.response',
'params' => [],
@@ -114,7 +135,9 @@ public function preOut(Manager $assets)
*/
public function outBound(Manager $assets)
{
-
+ if ($assets->provides('Proem\IO\Response\Template\Template')) {
+ $assets->get('response')->send();
+ }
}
/**
@@ -124,7 +147,7 @@ public function outBound(Manager $assets)
*/
public function postOut(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'post.out.response',
'params' => [],
View
33 lib/Proem/Api/Bootstrap/Filter/Event/Route.php
@@ -30,15 +30,18 @@
*/
namespace Proem\Api\Bootstrap\Filter\Event;
-use Proem\Service\Manager,
- Proem\Bootstrap\Signal\Event\Bootstrap;
+use Proem\Service\Manager\Template as Manager,
+ Proem\Bootstrap\Signal\Event\Bootstrap,
+ Proem\Service\Asset\Standard as Asset,
+ Proem\Routing\Router\Standard as Router,
+ Proem\Filter\Event\Generic as Event;
/**
* Proem\Api\Bootstrap\Filter\Event\Route
*
* The default "Route" filter event.
*/
-class Route extends \Proem\Filter\Event\Generic
+class Route extends Event
{
/**
* preIn
@@ -47,14 +50,18 @@ class Route extends \Proem\Filter\Event\Generic
*/
public function preIn(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'pre.in.route',
'params' => [],
'target' => $this,
'method' => __FUNCTION__,
'event' => (new Bootstrap())->setServiceManager($assets),
- 'callback' => function($e) {},
+ 'callback' => function($e) use ($assets) {
+ if ($e->provides('Proem\Routing\Router')) {
+ $assets->set('router', $e);
+ }
+ },
]);
}
}
@@ -66,7 +73,15 @@ public function preIn(Manager $assets)
*/
public function inBound(Manager $assets)
{
-
+ if (!$assets->provides('Proem\Routing\Router')) {
+ $asset = new Asset;
+ $assets->set(
+ 'router',
+ $asset->set('Proem\Routing\Router', $asset->single(function() use ($assets) {
+ return new Router($assets->get('request')->getRequestUri());
+ }))
+ );
+ }
}
/**
@@ -76,7 +91,7 @@ public function inBound(Manager $assets)
*/
public function postIn(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'post.in.route',
'params' => [],
@@ -95,7 +110,7 @@ public function postIn(Manager $assets)
*/
public function preOut(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'pre.out.route',
'params' => [],
@@ -124,7 +139,7 @@ public function outBound(Manager $assets)
*/
public function postOut(Manager $assets)
{
- if ($assets->provides('events', '\Proem\Signal\Manager')) {
+ if ($assets->provides('events', '\Proem\Signal\Manager\Template')) {
$assets->get('events')->trigger([
'name' => 'post.out.route',
'params' => [],
View
29 lib/Proem/Api/Bootstrap/Signal/Event/Bootstrap.php
@@ -30,14 +30,15 @@
*/
namespace Proem\Api\Bootstrap\Signal\Event;
-use Proem\Service\Manager;
+use Proem\Service\Manager\Template as Manager,
+ Proem\Signal\Event\Standard as StandardEvent;
/**
* Proem\Api\Bootstrap\Signal\Event\Bootstrap
*
* A custom event used by the bootstrap triggered events.
*/
-class Bootstrap extends \Proem\Signal\Event\Generic
+class Bootstrap extends StandardEvent
{
/**
* Store the service manager
@@ -45,6 +46,11 @@ class Bootstrap extends \Proem\Signal\Event\Generic
private $serviceManager;
/**
+ * Store the environment variable.
+ */
+ private $environment;
+
+ /**
* Set the service manager
*
* @param Proem\Api\Service\Manager $serviceManager
@@ -63,4 +69,23 @@ public function getServiceManager()
return $this->serviceManager;
}
+ /**
+ * Set the environment
+ *
+ * @param string $env
+ */
+ public function setEnvironment($environment)
+ {
+ $this->environment = $environment;
+ return $this;
+ }
+
+ /**
+ * Retrieve the environment
+ */
+ public function getEnvironment()
+ {
+ return $this->environment;
+ }
+
}
View
5 lib/Proem/Api/Ext/Module/Generic.php
@@ -30,14 +30,15 @@
*/
namespace Proem\Api\Ext\Module;
-use Proem\Service\Manager;
+use Proem\Ext\Template,
+ Proem\Service\Manager\Template as Manager;
/**
* Proem\Api\Ext\Module\Generic
*
* A base Module abstract
*/
-abstract class Generic extends \Proem\Ext\Generic
+abstract class Generic implements Template
{
public abstract function init(Manager $assets, $env = null);
}
View
5 lib/Proem/Api/Ext/Plugin/Generic.php
@@ -30,14 +30,15 @@
*/
namespace Proem\Api\Ext\Plugin;
-use Proem\Service\Manager;
+use Proem\Ext\Template,
+ Proem\Service\Manager\Template as Manager;
/**
* Proem\Api\Ext\Plugin\Generic
*
* A base Plugin sbstract
*/
-abstract class Generic extends \Proem\Ext\Generic
+abstract class Generic implements Template
{
public abstract function init(Manager $assets, $env = null);
}
View
12 lib/Proem/Api/Ext/Generic.php → lib/Proem/Api/Ext/Template.php
@@ -30,12 +30,12 @@
*/
namespace Proem\Api\Ext;
-use Proem\Service\Manager;
+use Proem\Service\Manager\Template as Manager;
/**
- * Proem\Api\Ext\Generic
- *
- * A base Module / Plugin.
+ * Proem\Api\Ext\Template
*/
-class Generic
-{}
+interface Template
+{
+ public function init(Manager $assets, $env = null);
+}
View
7 lib/Proem/Api/Filter/Event/Generic.php
@@ -30,13 +30,14 @@
*/
namespace Proem\Api\Filter\Event;
-use Proem\Filter\Manager as FilterManager,
- Proem\Service\Manager as ServiceManager;
+use Proem\Filter\Manager\Standard as FilterManager,
+ Proem\Service\Manager\Template as ServiceManager,
+ Proem\Filter\Event\Template as Template;
/**
* Proem\Api\Filter\Event\Generic
*/
-abstract class Generic
+abstract class Generic implements Template
{
/**
* preIn
View
43 lib/Proem/Api/Filter/Event/Template.php
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+/**
+ * @namespace Proem\Api\Filter\Event
+ */
+namespace Proem\Api\Filter\Event;
+
+use Proem\Service\Manager\Template as ServiceManager;
+
+/**
+ * Proem\Api\Filter\Event\Template
+ */
+interface Template
+{
+ public function inBound(ServiceManager $assets);
+
+ public function outBound(ServiceManager $assets);
+}
View
13 lib/Proem/Api/Filter/Manager.php → lib/Proem/Api/Filter/Manager/Standard.php
@@ -26,18 +26,19 @@
/**
- * @namespace Proem\Api\Filter
+ * @namespace Proem\Api\Filter\Manager
*/
-namespace Proem\Api\Filter;
+namespace Proem\Api\Filter\Manager;
-use Proem\Filter\Event\Generic as Event,
+use Proem\Filter\Event\Template as Event,
Proem\Util\Storage\Queue,
- Proem\Service\Manager as ServiceManager;
+ Proem\Service\Manager\Template as ServiceManager,
+ Proem\Filter\Manager\Template;
/**
- * Proem\Api\Filter\Manager
+ * Proem\Api\Filter\Manager\Standard
*/
-class Manager
+class Standard implements Template
{
/**
* Constants used to priorities default events
View
51 lib/Proem/Api/Filter/Manager/Template.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+/**
+ * @namespace Proem\Api\Filter\Manager
+ */
+namespace Proem\Api\Filter\Manager;
+
+use Proem\Filter\Event\Template as Event,
+ Proem\Util\Storage\Queue,
+ Proem\Service\Manager as ServiceManager;
+
+/**
+ * Proem\Api\Filter\Manager\Template
+ */
+interface Template
+{
+ public function attachEvent(Event $event, $priority);
+
+ public function getInitialEvent();
+
+ public function getNextEvent();
+
+ public function hasEvents();
+
+ public function init();
+}
View
11 lib/Proem/Api/IO/Http/FakeRequest.php → lib/Proem/Api/IO/Request/Http/Fake.php
@@ -31,16 +31,17 @@
*/
/**
- * @namespace Proem\Api\IO\Http
+ * @namespace Proem\Api\IO\Request\Http
*/
-namespace Proem\Api\IO\Http;
+namespace Proem\Api\IO\Request\Http;
-use Proem\Util\Storage\KeyValStore;
+use Proem\IO\Request\Template,
+ Proem\Util\Storage\KeyValStore;
/**
- * Proem\Api\IO\Http\FakeRequest
+ * Proem\Api\IO\Request\Http\Fake
*/
-class FakeRequest extends Request
+class Fake extends Standard
{
/**
* Instantiate a post from faked data.
View
13 lib/Proem/Api/IO/Http/Request.php → lib/Proem/Api/IO/Request/Http/Standard.php
@@ -26,16 +26,17 @@
/**
- * @namespace Proem\Api\IO\Http
+ * @namespace Proem\Api\IO\Request\Http
*/
-namespace Proem\Api\IO\Http;
+namespace Proem\Api\IO\Request\Http;
-use Proem\Util\Storage\KeyValStore;
+use Proem\IO\Request\Template,
+ Proem\Util\Storage\KeyValStore;
/**
- * Proem\Api\IO\Http\Request
+ * Proem\Api\IO\Http\Request\Standard
*/
-class Request
+class Standard implements Template
{
/**
* Store data internally
@@ -76,7 +77,7 @@ public function __construct(array $param = []) {
'param' => new KeyValStore($param),
'get' => new KeyValStore($_GET),
'post' => new KeyValStore($_POST),
- 'cookie' => new KeyValStore($_COOKIES),
+ 'cookie' => new KeyValStore($_COOKIE),
'file' => new KeyValStore($_FILES),
'meta' => new KeyValStore($_SERVER),
'header' => new KeyValStore($this->formHeaders($_SERVER))
View
21 bin/new-file → lib/Proem/Api/IO/Request/Template.php 100755 → 100644
@@ -1,7 +1,3 @@
-#!/usr/bin/env php
-<?php
-
-$header = <<<EOD
<?php
/**
@@ -30,21 +26,14 @@
/**
- * @namespace Proem\
+ * @namespace Proem\Api\IO\Request
*/
-namespace Proem\;
+namespace Proem\Api\IO\Request;
/**
- * Proem\
- *
- *
+ * Proem\Api\IO\Request\Template
*/
-class
+interface Template
{
-
-}
-EOD;
-
-if ($argc == 2) {
- file_put_contents($argv[1], $header);
+ public function getBody($raw = true);
}
View
13 lib/Proem/Api/IO/Http/Response.php → lib/Proem/Api/IO/Response/Http/Standard.php
@@ -26,18 +26,17 @@
/**
- * @namespace Proem\Api\IO\Http
+ * @namespace Proem\Api\IO\Response\Http
*/
-namespace Proem\Api\IO\Http;
+namespace Proem\Api\IO\Response\Http;
-use Proem\Util\Storage\KeyValStore;
+use Proem\IO\Response\Template,
+ Proem\Util\Storage\KeyValStore;
/**
- * Proem\Api\IO\Http\Response
- *
- * TODO: Implement cookie handling.
+ * Proem\Api\IO\Response\Http\Standard
*/
-class Response
+class Standard implements Template
{
/**
* Store the HTTP Version
View
44 lib/Proem/Api/IO/Response/Template.php
@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+/**
+ * @namespace Proem\Api\IO\Response
+ */
+namespace Proem\Api\IO\Response;
+
+/**
+ * Proem\Api\IO\Response\Template
+ *
+ */
+interface Template
+{
+ public function appendToBody($string);
+
+ public function getBody();
+
+ public function send();
+}
View
76 lib/Proem/Api/Proem.php
@@ -29,13 +29,16 @@
*/
namespace Proem\Api;
-use Proem\Service\Manager as ServiceManager,
- Proem\Signal\Manager as SignalManager,
- Proem\Service\Asset\Generic as Asset,
- Proem\Bootstrap\Filter\Event,
+use Proem\Service\Manager\Standard as ServiceManager,
+ Proem\Signal\Manager\Standard as SignalManager,
+ Proem\Filter\Manager\Standard as FilterManager,
+ Proem\Service\Asset\Standard as Asset,
+ Proem\Bootstrap\Filter\Event\Dispatch,
+ Proem\Bootstrap\Filter\Event\Response,
+ Proem\Bootstrap\Filter\Event\Request,
+ Proem\Bootstrap\Filter\Event\Route,
Proem\Bootstrap\Signal\Event\Bootstrap,
- Proem\Filter\Manager as FilterManager,
- Proem\Ext\Generic as Extension,
+ Proem\Ext\Template as Extension,
Proem\Ext\Module\Generic as Module,
Proem\Ext\Plugin\Generic as Plugin;
@@ -49,7 +52,7 @@ class Proem
/**
* Store the framework version
*/
- const VERSION = '0.2.0';
+ const VERSION = '0.2.5';
/**
* Store events
@@ -58,27 +61,20 @@ class Proem
*/
private $events;
- /**
- * Store Modules / Plugins
- */
- private $extensions = [];
-
- /**
- * Bootstrap Extensions
- */
- private function bootstrapExtensions(ServiceManager $serviceManager, $env = null)
- {
- foreach ($this->extensions as $extension) {
- $extension->init($serviceManager, $env);
- }
- }
+ private $serviceManager;
/**
* Register Modules / Plugins
*/
- private function attachExtension(Extension $extension)
+ private function attachExtension(Extension $extension, $event = 'proem.init', $priority = 0)
{
- $this->extensions[] = $extension;
+ $this->attachEventListener([
+ 'name' => $event,
+ 'priority' => $priority,
+ 'callback' => function($e) use ($extension) {
+ $extension->init($e->getServiceManager(), $e->getEnvironment());
+ }
+ ]);
return $this;
}
@@ -88,9 +84,11 @@ private function attachExtension(Extension $extension)
public function __construct()
{
$this->events = new Asset;
- $this->events->set('\Proem\Signal\Manager', $this->events->single(function($asset) {
+ $this->events->set('\Proem\Signal\Manager\Template', $this->events->single(function($asset) {
return new SignalManager;
}));
+
+ $this->serviceManager = new ServiceManager;
}
/**
@@ -116,7 +114,7 @@ public function attachEventListeners(Array $listeners)
/**
* Register a Plugin
*/
- public function attachPlugin(Plugin $plugin)
+ public function attachPlugin(Plugin $plugin, $event = 'proem.init', $priority = 0)
{
return $this->attachExtension($plugin);
}
@@ -124,24 +122,30 @@ public function attachPlugin(Plugin $plugin)
/**
* Register a Module
*/
- public function attachModule(Extension $module)
+ public function attachModule(Module $module, $event = 'proem.init', $priority = 0)
{
- return $this->attachExtension($module);
+ return $this->attachExtension($module, $event, $priority);
}
/**
* Setup and execute the Filter Manager
*/
- public function init($env = null)
+ public function init($environment = null)
{
- $serviceManager = (new ServiceManager)->set('events', $this->events);
- $this->bootstrapExtensions($serviceManager, $env);
-
- (new FilterManager($serviceManager))
- ->attachEvent(new Event\Response, FilterManager::RESPONSE_EVENT_PRIORITY)
- ->attachEvent(new Event\Request, FilterManager::REQUEST_EVENT_PRIORITY)
- ->attachEvent(new Event\Route, FilterManager::ROUTE_EVENT_PRIORITY)
- ->attachEvent(new Event\Dispatch, FilterManager::DISPATCH_EVENT_PRIORITY)
+ $this->serviceManager->set('events', $this->events);
+
+ $this->events->get()->trigger([
+ 'name' => 'proem.init',
+ 'event' => (new Bootstrap)
+ ->setServiceManager($this->serviceManager)
+ ->setEnvironment($environment)
+ ]);
+
+ (new FilterManager($this->serviceManager))
+ ->attachEvent(new Response, FilterManager::RESPONSE_EVENT_PRIORITY)
+ ->attachEvent(new Request, FilterManager::REQUEST_EVENT_PRIORITY)
+ ->attachEvent(new Route, FilterManager::ROUTE_EVENT_PRIORITY)
+ ->attachEvent(new Dispatch, FilterManager::DISPATCH_EVENT_PRIORITY)
->init();
}
}
View
5 lib/Proem/Api/Routing/Route/Generic.php
@@ -33,12 +33,13 @@
use Proem\Dispatch\Payload,
Proem\Util\Opt\Options,
Proem\Util\Opt\Option,
- Proem\Util\ArrayHelper;
+ Proem\Util\ArrayHelper,
+ Proem\Routing\Route\Template;
/**
* Proem\Api\Routing\Route
*/
-abstract class Generic
+abstract class Generic implements Template
{
use Options;
use ArrayHelper;
View
3 lib/Proem/Api/Routing/Route/Standard.php
@@ -30,7 +30,8 @@
*/
namespace Proem\Api\Routing\Route;
-use Proem\Routing\Route\Generic;
+use Proem\Routing\Route\Template,
+ Proem\Routing\Route\Generic;
/**
* Proem\Api\Routing\Route\Standard
View
39 lib/Proem/Api/Routing/Route/Template.php
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+/**
+ * @namespace Proem\Api\Routing\Route
+ */
+namespace Proem\Api\Routing\Route;
+
+/**
+ * Proem\Api\Routing\Route\Template
+ */
+interface Template
+{
+ public function process($uri);
+}
View
10 lib/Proem/Api/Routing/Router.php → lib/Proem/Api/Routing/Router/Standard.php
@@ -26,16 +26,16 @@
/**
- * @namespace Proem\Api\Routing
+ * @namespace Proem\Api\Routing\Router
*/
-namespace Proem\Api\Routing;
+namespace Proem\Api\Routing\Router;
-use Proem\Routing\Route\Generic as Route;
+use Proem\Routing\Route\Template as Route;
/**
- * Proem\Api\Routing\Router
+ * Proem\Api\Routing\Router\Standard
*/
-class Router
+class Standard implements Template
{
/**
* Store the request url
View
43 lib/Proem/Api/Routing/Router/Template.php
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+/**
+ * @namespace Proem\Api\Routing\Router
+ */
+namespace Proem\Api\Routing\Router;
+
+use Proem\Routing\Route\Template as Route;
+
+/**
+ * Proem\Api\Routing\Route\Template
+ */
+interface Template
+{
+ public function map($name, Route $route);
+
+ public function route();
+}
View
7 lib/Proem/Api/Service/Asset/Generic.php → lib/Proem/Api/Service/Asset/Standard.php
@@ -30,10 +30,11 @@
*/
namespace Proem\Api\Service\Asset;
-use Proem\Service\Manager;
+use Proem\Service\Asset\Template,
+ Proem\Service\Manager\Template as Manager;
/**
- * Proem\Api\Service\Asset\Generic
+ * Proem\Api\Service\Asset\Standard
*
* An Asset container.
*
@@ -42,7 +43,7 @@
* as well as having the ability to ijnstantiate an object using these parameters via a
* Closure.
*/
-class Generic
+class Standard implements Template
{
/**
* Store any required parameters
View
55 lib/Proem/Api/Service/Asset/Template.php
@@ -0,0 +1,55 @@
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+/**
+ * @namespace Proem\Api\Service\Asset
+ */
+namespace Proem\Api\Service\Asset;
+
+use Proem\Service\Manager\Template as Manager;
+
+/**
+ * Proem\Api\Service\Asset\Template
+ */
+interface Template
+{
+ public function provides();
+
+ public function setParam($index, $value);
+
+ public function setParams(array $params);
+
+ public function getParam($index);
+
+ public function getParams();
+
+ public function set($provides, \Closure $closure);
+
+ public function get(Manager $assetManager = null);
+
+ public function single(\Closure $closure);
+}
View
15 lib/Proem/Api/Service/Manager.php → lib/Proem/Api/Service/Manager/Standard.php
@@ -26,14 +26,15 @@
/**
- * @namespace Proem\Api\Service
+ * @namespace Proem\Api\Service\Manager
*/
-namespace Proem\Api\Service;
+namespace Proem\Api\Service\Manager;
-use Proem\Service\Asset\Generic as Asset;
+use Proem\Service\Manager\Template,
+ Proem\Service\Asset\Template as Asset;
/**
- * Proem\Api\Service\Manager
+ * Proem\Api\Service\Manager\Standard
*
* A Registry of Assets.
*
@@ -43,9 +44,9 @@
* These containers contain the parameters required to instantiate an Asset as
* well as a Closure capable of returning a configured and instantiated Asset.
*
- * @see Proem\Api\Service\Asset\Generic
+ * @see Proem\Api\Service\Asset\Standard
*/
-class Manager
+class Standard implements Template
{
/**
* Store assets
@@ -64,7 +65,7 @@ class Manager
* Store an Asset container by named index.
*
* @param string $index The index the asset will be referenced by.
- * @param Proem\Api\Service\Asset\Generic $asset
+ * @param Proem\Api\Service\Asset\Template $asset
*/
public function set($index, Asset $asset)
{
View
51 lib/Proem/Api/Service/Manager/Template.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+/**
+ * @namespace Proem\Api\Service\Manager
+ */
+namespace Proem\Api\Service\Manager;
+
+use Proem\Service\Asset\Template as Asset;
+
+/**
+ * Proem\Api\Service\Manager\Template
+ */
+interface Template
+{
+ public function set($index, Asset $asset);
+
+ public function getContainer($index);
+
+ public function get($index);
+
+ public function has($index);
+
+ public function provides($index, $provides = null);
+
+ public function getProvided($provides);
+}
View
24 lib/Proem/Api/Signal/Event/Generic.php → lib/Proem/Api/Signal/Event/Standard.php
@@ -31,14 +31,15 @@
namespace Proem\Api\Signal\Event;
use Proem\Util\Opt\Options,
- Proem\Util\Opt\Option;
+ Proem\Util\Opt\Option,
+ Proem\Signal\Event\Template;
/**
- * Proem\Api\Signal\Event\Generic
+ * Proem\Api\Signal\Event\Standard
*
* A base Event implementation
*/
-class Generic
+class Standard implements Template
{
/**
* Make use of the Options trait
@@ -69,7 +70,7 @@ class Generic
/**
* Set params
*/
- public function setParams(Array $params)
+ public function setParams(array $params)
{
$this->params = $params;
return $this;
@@ -78,7 +79,8 @@ public function setParams(Array $params)
/**
* Retrieve any parameters passed to this Event
*/
- public function getParams() {
+ public function getParams()
+ {
return $this->params;
}
@@ -87,7 +89,8 @@ public function getParams() {
*
* The target should be an instance of whatever object this event was triggered from
*/
- public function setTarget($target) {
+ public function setTarget($target)
+ {
$this->target = $target;
return $this;
}
@@ -97,7 +100,8 @@ public function setTarget($target) {
*
* The target should be an instance of whatever object this event was triggered from
*/
- public function getTarget() {
+ public function getTarget()
+ {
return $this->target;
}
@@ -106,7 +110,8 @@ public function getTarget() {
*
* The method should be a string representing the name of the method which has triggered this event
*/
- public function setMethod($method) {
+ public function setMethod($method)
+ {
$this->method = $method;
return $this;
}
@@ -116,7 +121,8 @@ public function setMethod($method) {
*
* The method should be a string containing the name of the function this event was triggered from
*/
- public function getMethod() {
+ public function getMethod()
+ {
return $this->method;
}
View
52 lib/Proem/Api/Signal/Event/Template.php
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+/**
+ * @namespace Proem\Api\Signal\Event
+ */
+namespace Proem\Api\Signal\Event;
+
+use Proem\Util\Opt\Options,
+ Proem\Util\Opt\Option;
+
+/**
+ * Proem\Api\Signal\Event\Template
+ */
+interface Template
+{
+ public function setParams(array $params);
+
+ public function getParams();
+
+ public function setTarget($target);
+
+ public function getTarget();
+
+ public function setMethod($method);
+
+ public function getMethod();
+}
View
21 lib/Proem/Api/Signal/Manager.php → lib/Proem/Api/Signal/Manager/Standard.php
@@ -26,22 +26,23 @@
/**
- * @namespace Proem\Api\Signal
+ * @namespace Proem\Api\Signal\Manager
*/
-namespace Proem\Api\Signal;
+namespace Proem\Api\Signal\Manager;
use Proem\Util\Storage\Queue,
Proem\Util\Process\Callback,
Proem\Util\Opt\Options,
Proem\Util\Opt\Option,
- Proem\Signal\Event\Generic as Event;
+ Proem\Signal\Event\Standard as Event,
+ Proem\Signal\Manager\Template;
/**
- * Proem\Api\Signal\Manager
+ * Proem\Api\Signal\Manager\Standard
*
* Manage the registration of and triggering of Events.
*/
-class Manager
+class Standard implements Template
{
/**
* Make use of the Options trait
@@ -74,7 +75,7 @@ class Manager
* ], $options);
* </code>
*/
- public function attach(Array $options)
+ public function attach(array $options)
{
$ops = $this->setOptions([
'name' => (new Option())->required(),
@@ -103,11 +104,11 @@ public function attach(Array $options)
* 'callback' => (new Option())->type('callable'),
* 'target' => (new Option())->type('object'),
* 'method' => (new Option())->type('string'),
- * 'event' => (new Option(new Event))->object('\Proem\Signal\Event\Generic')
+ * 'event' => (new Option(new Event))->object('\Proem\Signal\Event\Template')
* ], $options);
* </code>
*/
- public function trigger(Array $options)
+ public function trigger(array $options)
{
$ops = $this->setOptions([
'name' => (new Option())->required(),
@@ -115,13 +116,13 @@ public function trigger(Array $options)
'callback' => (new Option())->type('callable'),
'target' => (new Option())->type('object'),
'method' => (new Option())->type('string'),
- 'event' => (new Option(new Event))->object('\Proem\Signal\Event\Generic')
+ 'event' => (new Option(new Event))->object('\Proem\Signal\Event\Template')
], $options);
if (isset($this->queues[$ops->name])) {
foreach ($this->queues[$ops->name] as $event) {
$eventObj = $ops->event;
- if ($eventObj instanceof \Proem\Signal\Event\Generic) {
+ if ($eventObj instanceof \Proem\Signal\Event\Template) {
if ($ops->has('params')) {
$eventObj->setParams($ops->params);
}
View
41 lib/Proem/Api/Signal/Manager/Template.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+/**
+ * @namespace Proem\Api\Signal\Manager
+ */
+namespace Proem\Api\Signal\Manager;
+
+/**
+ * Proem\Api\Signal\Manager\Template
+ */
+interface Template
+{
+ public function attach(array $options);
+
+ public function trigger(array $options);
+}
View
6 lib/Proem/Api/Util/Opt/Option.php
@@ -31,8 +31,8 @@
namespace Proem\Api\Util\Opt;
use Proem\Util\Process\Callback,
- Proem\Service\Asset\Generic as GenericAsset,
- Proem\Service\Manager as ServiceManager;
+ Proem\Service\Asset\Standard as StandardAsset,
+ Proem\Service\Manager\Template as ServiceManager;
/**
* Proem\Api\Util\Opt\Option
@@ -237,7 +237,7 @@ public function validate($options = []) {
}
if ($this->is_asset && $this->value !== __FILE__) {
- if ($this->value instanceof GenericAsset) {
+ if ($this->value instanceof StandardAsset) {
if ($this->value->provides() !== $this->is_asset) {
if ($this->throws === null) {
throw new \InvalidArgumentException(' did not pass the "' . $this->is_asset . '" Asset validator');
View
1 phake
View
19 tests/lib/Proem/Tests/Ext/Fixtures/MyApp/Module/Foo.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace MyApp\Module;
+
+use \Proem\Service\Manager\Template as Manager;
+
+class Foo extends \Proem\Ext\Module\Generic
+{
+ public function init(Manager $assets, $env = null) {
+ $assets->get('events')->attach([
+ 'name' => 'pre.in.route',
+ 'callback' => [$this, 'loadRoutes']
+ ]);
+ }
+
+ public function loadRoutes($e) {
+ echo 'Foo Module Loaded';
+ }
+}
View
64 tests/lib/Proem/Tests/ExtTest.php
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Proem\Tests;
+
+use Proem\Autoloader,
+ MyApp\Module\Foo;
+
+class ExtTest extends \PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ (new Autoloader)
+ ->registerNamespace('MyApp', dirname(__FILE__) . '/Ext/Fixtures')
+ ->register();
+ }
+
+ public function testFooModuleLoads()
+ {
+ $this->expectOutputString('Foo Module Loaded');
+
+ (new \Proem\Proem)
+ ->attachModule(new Foo)
+ ->init();
+ }
+
+ /**
+ * The Foo module listens for the pre.in.route signal event,
+ * Loading it now (at post.in.route) will never give it a chance
+ * to set itself up.
+ */
+ public function testFooModuleWontLoadWhenAttachedTooLate()
+ {
+ $this->expectOutputString('');
+
+ (new \Proem\Proem)
+ ->attachModule(new Foo, 'post.in.route')
+ ->init();
+ }
+
+}
View
6 tests/lib/Proem/Tests/FilterTest.php
@@ -26,8 +26,8 @@
namespace Proem\Tests;
-use Proem\Filter\Manager as FilterManager,
- Proem\Service\Manager as ServiceManager;
+use Proem\Filter\Manager\Standard as FilterManager,
+ Proem\Service\Manager\Standard as ServiceManager;
class FilterTest extends \PHPUnit_Framework_TestCase
{
@@ -44,7 +44,7 @@ public function setUp() {
}
public function testCanInstantiate()
{
- $this->assertInstanceOf('Proem\Filter\Manager', new FilterManager(new ServiceManager));
+ $this->assertInstanceOf('Proem\Filter\Manager\Standard', new FilterManager(new ServiceManager));
}
public function testFilterManagerRun() {
View
4 tests/lib/Proem/Tests/Fixtures/Proem/Ext/Plugin/Foo.php
@@ -30,8 +30,8 @@
*/
namespace Proem\Ext\Plugin;
-use Proem\Service\Manager,
- Proem\Service\Asset\Generic as Asset;
+use Proem\Service\Manager\Template as Manager,
+ Proem\Service\Asset\Standard as Asset;
/**
* Proem\Ext\Plugin\Foo
View
2 tests/lib/Proem/Tests/Fixtures/Proem/Service/Asset/Bar.php
@@ -26,7 +26,7 @@
namespace Proem\Service\Asset;
-class Bar
+class Bar extends \Proem\Service\Asset\Standard
{
public function hello()
{
View
2 tests/lib/Proem/Tests/Fixtures/Proem/Service/Asset/Foo.php
@@ -26,7 +26,7 @@
namespace Proem\Service\Asset;
-class Foo
+class Foo extends \Proem\Service\Asset\Standard
{
private $name;
private $bar;
View
14 tests/lib/Proem/Tests/IO/Http/FakeRequestTest.php
@@ -26,30 +26,30 @@
namespace Proem\Tests\IO\Http;
-use Proem\IO\Http\FakeRequest;
+use Proem\IO\Request\Http\Fake;
class FakeRequestTest extends \PHPUnit_Framework_TestCase
{
public function testCanInstantiate()
{
- $this->assertInstanceOf('\Proem\IO\Http\FakeRequest', new FakeRequest(null));
+ $this->assertInstanceOf('\Proem\IO\Request\Template', new Fake(null));
}
public function testMagicGet()
{
- $this->assertInstanceOf('\Proem\Util\Storage\KeyValStore', (new FakeRequest(null))->get);
+ $this->assertInstanceOf('\Proem\Util\Storage\KeyValStore', (new Fake(null))->get);
}
public function testParsedComponents()
{
- $request = new FakeRequest('http://proemframework.org/foo/bar');
+ $request = new Fake('http://proemframework.org/foo/bar');
$this->assertEquals('/foo/bar', $request->getRequestUri());
$this->assertEquals('proemframework.org', $request->getHostName());
}