Permalink
Browse files

Merge branch 'release-0.1.1'

  • Loading branch information...
2 parents 072e876 + a30d975 commit 11330abc1555e128d191238cbfe7ebc995f1b809 @trq trq committed Jan 18, 2012
@@ -26,15 +26,15 @@
/**
- * @namespace Proem\Api
+ * @namespace Proem\Api\Bootstrap
*/
-namespace Proem\Api;
+namespace Proem\Api\Bootstrap;
-use Proem\Chain\Event,
- Proem\Util\Queue;
+use Proem\Bootstrap\Event\Generic as Event,
+ Proem\Util\Storage\Queue;
/**
- * Proem\Api\Chain
+ * Proem\Api\Bootstrap\Chain
*/
class Chain
{
@@ -26,16 +26,16 @@
/**
- * @namespace Proem\Api\Chain
+ * @namespace Proem\Api\Bootstrap\Event
*/
-namespace Proem\Api\Chain;
+namespace Proem\Api\Bootstrap\Event;
-use Proem\Api\Chain;
+use Proem\Bootstrap\Chain;
/**
- * Proem\Api\Chain\Event
+ * Proem\Api\Bootstrap\Event\Generic
*/
-abstract class Event
+abstract class Generic
{
/**
* inBound
@@ -25,17 +25,17 @@
*/
/**
- * @namespace Proem\Api
+ * @namespace Proem\Api\Loader
*/
-namespace Proem\Api;
+namespace Proem\Api\Loader;
/**
- * Proem\Api\Autoloader
+ * Proem\Api\Loader\Auto
*/
-class Autoloader
+class Auto
{
- private $namespaces = array();
- private $pearPrefixes = array();
+ private $namespaces = [];
+ private $pearPrefixes = [];
/**
* Register an array of namespaces.
View
@@ -36,5 +36,5 @@
*/
class Proem
{
- const VERSION = '0.1.0';
+ const VERSION = '0.1.1';
}
@@ -26,14 +26,14 @@
/**
- * @namespace Proem
+ * @namespace Proem\Api\Service\Asset
*/
-namespace Proem\Api;
+namespace Proem\Api\Service\Asset;
-use Proem\Asset\Manager;
+use Proem\Service\Manager;
/**
- * Proem\Asset
+ * Proem\Api\Service\Asset\Generic
*
* An Asset container.
*
@@ -42,7 +42,7 @@
* as well as having the ability to ijnstantiate an object using these parameters via a
* Closure.
*/
-class Asset
+class Generic
{
/**
* Store any required parameters
@@ -70,6 +70,27 @@ public function setParam($index, $value)
return $this;
}
+ /**
+ * A maigic method shortcut that proxies setParam()
+ *
+ * @param string $index
+ * @param mixed $value
+ */
+ public function __set($index, $value) {
+ return $this->setParam($index, $value);
+ }
+
+ /**
+ * Set multiple parameters use a key => value array
+ *
+ * @param array $params
+ */
+ public function setParams(Array $params)
+ {
+ $this->params = array_merge($this->params, $params);
+ return $this;
+ }
+
/**
* Retrieve a parameter by named index
*
@@ -80,12 +101,29 @@ public function getParam($index)
return isset($this->params[$index]) ? $this->params[$index] : null;
}
+ /**
+ * A maigic method shortcut that proxies getParam()
+ *
+ * @param string $index
+ */
+ public function __get($index) {
+ return $this->getParam($index);
+ }
+
+ /**
+ * Retrieve all parameters as an array.
+ */
+ public function getParams()
+ {
+ return $this->params;
+ }
+
/**
* Store the Closure reponsible for instantiating an Asset
*
* @param Closure $closure
*/
- public function setAsset(\Closure $closure)
+ public function set(\Closure $closure)
{
$this->asset = $closure;
return $this;
@@ -102,7 +140,7 @@ public function setAsset(\Closure $closure)
*
* @param Proem\Api\Asset\Manager $assetManager
*/
- public function getAsset(Manager $assetManager = null)
+ public function get(Manager $assetManager = null)
{
$asset = $this->asset;
return $asset($this, $assetManager);
@@ -26,14 +26,14 @@
/**
- * @namespace Proem\Api\Asset
+ * @namespace Proem\Api\Service
*/
-namespace Proem\Api\Asset;
+namespace Proem\Api\Service;
-use Proem\Asset;
+use Proem\Service\Asset\Generic as Asset;
/**
- * Proem\Api\Asset\Manager
+ * Proem\Api\Service\Manager
*
* A Registry of Assets.
*
@@ -43,7 +43,7 @@
* 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\Asset
+ * @see Proem\Api\Service\Asset\Generic
*/
class Manager
{
@@ -60,7 +60,7 @@ class Manager
* @param string $index The index the asset will be referenced by.
* @param Proem\Api\Asset $asset
*/
- public function setAsset($index, Asset $asset)
+ public function set($index, Asset $asset)
{
$this->assets[$index] = $asset;
return $this;
@@ -81,9 +81,19 @@ public function getContainer($index)
*
* @param string $index The index the asset is referenced by.
*/
- public function getAsset($index)
+ public function get($index)
{
- return isset($this->assets[$index]) ? $this->assets[$index]->getAsset($this) : null;
+ return isset($this->assets[$index]) ? $this->assets[$index]->get($this) : null;
+ }
+
+ /**
+ * Check to see if this manager has a specific asset
+ *
+ * @param string $index The index the asset is referenced by.
+ */
+ public function has($index)
+ {
+ return isset($this->assets[$index]);
}
}
@@ -26,19 +26,19 @@
/**
- * @namespace Proem\Api\Event
+ * @namespace Proem\Api\Signal\Event
*/
-namespace Proem\Api;
+namespace Proem\Api\Signal\Event;
-use Proem\Util\Options,
- Proem\Util\Options\Option;
+use Proem\Util\Opt\Options,
+ Proem\Util\Opt\Option;
/**
- * Proem\Api\Event
+ * Proem\Api\Signal\Event\Generic
*
* A base Event implementation
*/
-class Event
+class Generic
{
/**
* Make use of the Options trait
@@ -52,6 +52,20 @@ class Event
*/
private $options;
+ /**
+ * Store target
+ *
+ * @var object $target
+ */
+ private $target = null;
+
+ /**
+ * Store the method
+ *
+ * @var string
+ */
+ private $method = null;
+
/**
* Instantiate the Event and setup any options
*
@@ -63,25 +77,55 @@ class Event
* ], $options);
* </code>
*/
- public function __construct(Array $options) {
+ public function __construct(Array $options = []) {
$this->options = $this->setOptions([
- 'name' => (new Option())->required(),
- 'params' => (new Option())->type('array')
+ 'params' => (new Option([]))->type('array'),
], $options);
}
/**
- * Retrieve the name of this event
+ * Retrieve any parameters passed to this Event
*/
- public function getName() {
- return $this->options->name;
+ public function getParams() {
+ return $this->options->params;
}
/**
- * Retrieve any parameters passed to this Event
+ * Set the target.
+ *
+ * The target should be an instance of whatever object this event was triggered from
*/
- public function getParams() {
- return $this->options->params;
+ public function setTarget($target) {
+ $this->target = $target;
+ return $this;
+ }
+
+ /**
+ * Retrieve target.
+ *
+ * The target should be an instance of whatever object this event was triggered from
+ */
+ public function getTarget() {
+ return $this->target;
+ }
+
+ /**
+ * Set the method.
+ *
+ * The method should be a string representing the name of the method which has triggered this event
+ */
+ public function setMethod($method) {
+ $this->method = $method;
+ return $this;
+ }
+
+ /**
+ * Retrieve method
+ *
+ * The method should be a string containing the name of the function this event was triggered from
+ */
+ public function getMethod() {
+ return $this->method;
}
}
@@ -26,18 +26,18 @@
/**
- * @namespace Proem\Api
+ * @namespace Proem\Api\Signal
*/
-namespace Proem\Api\Event;
+namespace Proem\Api\Signal;
-use Proem\Util\Queue,
- Proem\Util\Callback,
- Proem\Util\Options,
- Proem\Util\Options\Option,
- Proem\Event;
+use Proem\Util\Storage\Queue,
+ Proem\Util\Process\Callback,
+ Proem\Util\Opt\Options,
+ Proem\Util\Opt\Option,
+ Proem\Signal\Event\Generic as Event;
/**
- * Proem\Api\Event\Manager
+ * Proem\Api\Signal\Manager
*
* Manage the registration of and triggering of Events.
*/
@@ -108,21 +108,25 @@ public function attach(Array $options)
public function trigger(Array $options)
{
$ops = $this->setOptions([
- 'name' => (new Option())->required()->unless('event'),
+ 'name' => (new Option())->required(),
'params' => (new Option())->type('array'),
'callback' => (new Option())->type('callable'),
- 'event' => (new Option(new Event(['name' => $options['name']])))->object('\Proem\Event')
+ 'target' => (new Option())->type('object'),
+ 'method' => (new Option())->type('string'),
+ 'event' => (new Option(new Event))->object('\Proem\Signal\Event\Generic')
], $options);
if (isset($this->queues[$ops->name])) {
$this->queues[$ops->name]->rewind();
foreach ($this->queues[$ops->name] as $event) {
$eventObj = $ops->event;
if (isset($ops->params)) {
- $eventObj = new $eventObj(['name' => $ops->name, 'params' => $ops->params]);
+ $eventObj = new $eventObj(['params' => $ops->params]);
} else {
- $eventObj = new $eventObj(['name' => $ops->name]);
+ $eventObj = new $eventObj;
}
+ $eventObj->setTarget($ops->target);
+ $eventObj->setMethod($ops->method);
if ($return = $event($eventObj)) {
if (isset($ops->callback)) {
(new Callback($ops->callback, $return))->call();
Oops, something went wrong.

0 comments on commit 11330ab

Please sign in to comment.