Permalink
Browse files

Merge branch 'release-0.1.5'

  • Loading branch information...
2 parents 5c9fec8 + bf9c68f commit 8177e899180e067b2917d75fdd66120bd8eaaf5c @trq trq committed Feb 11, 2012
View
Binary file not shown.
@@ -0,0 +1,123 @@
+<?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\Dispatch
+ */
+namespace Proem\Api\Dispatch;
+
+use Proem\Util\Storage\KeyValStore;
+
+/**
+ * Proem\Api\Dispatch\Payload
+ */
+class Payload
+{
+ /**
+ * A flag to keep note as to wether or not this Payload is populated
+ *
+ * @var bool
+ */
+ private $populated = false;
+
+ /**
+ * Store the actual data.
+ *
+ * @var array
+ */
+ private $data = array();
+
+ public function __construct()
+ {
+ $this->data = new KeyValStore;
+ }
+
+ /**
+ * Store a parameter.
+ *
+ * @param string $name
+ * @param string|array $value
+ * @return Command
+ */
+ public function setParam($name, $value)
+ {
+ $this->data->set($name, $value);
+ return $this;
+ }
+
+ /**
+ * Store multiple params.
+ *
+ * @param array $params
+ */
+ public function setParams(array $params)
+ {
+ foreach ($params as $index => $value) {
+ $this->setParam($index, $value);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Retrieve a parameter or an optional default.
+ *
+ * @param string $name
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getParam($name, $default = null)
+ {
+ return $this->data->get($name, $default);
+ }
+
+ /**
+ * Retrieve all parameters as KeyValStore.
+ *
+ * @return array
+ */
+ public function getParams()
+ {
+ return $this->data;
+ }
+
+ /**
+ * Is the Payload Populated?
+ */
+ public function isPopulated()
+ {
+ return $this->populated;
+ }
+
+ /**
+ * Set the populated flag
+ */
+ public function setPopulated()
+ {
+ $this->populated = true;
+ }
+}
@@ -118,6 +118,22 @@ class Response
public function __construct()
{
$this->headers = new KeyValStore;
+ $this->headers->set('X-Powered-By','Proem Framework ' . \Proem\Proem::VERSION);
+ }
+
+ /**
+ * Silence the X-Powered-By header produced by Proem.
+ *
+ * This header produces X-Powered-By: Proem Framework X.X.X
+ * and may pose a security concern. It's just here as an easter
+ * egg more than anything. Removing it from this Request may
+ * not remove it all together as PHP itself can produce this
+ * same heeader.
+ */
+ public function silence()
+ {
+ $this->headers->remove('X-Powered-By');
+ return $this;
}
/**
View
@@ -49,7 +49,7 @@ class Proem
/**
* Store the framework version
*/
- const VERSION = '0.1.4';
+ const VERSION = '0.1.5';
/**
* Store events
@@ -0,0 +1,117 @@
+<?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;
+
+use Proem\Dispatch\Payload,
+ Proem\Util\Opt\Options,
+ Proem\Util\Opt\Option,
+ Proem\Util\ArrayHelper;
+
+/**
+ * Proem\Api\Routing\Route
+ */
+abstract class Generic
+{
+ use Options;
+ use ArrayHelper;
+
+ /**
+ * Store the options for this route
+ */
+ protected $options = [];
+
+ /**
+ * Store a flag indicating a route match
+ *
+ * @var bool
+ */
+ protected $matched = false;
+
+ /**
+ * Store matched parameters within a Dispatch\Payload object.
+ */
+ protected $payload = null;
+
+ /**
+ * Instantiate this route
+ */
+ public function __construct(array $options)
+ {
+ $this->options = $this->setOptions([
+ 'rule' => (new Option(''))->type('string'),
+ 'targets' => (new Option([]))->type('array'),
+ 'filters' => (new Option([]))->type('array')
+ ], $options);
+ }
+
+ /**
+ * Was a match found?
+ *
+ * @return bool
+ */
+ public function isMatch()
+ {
+ return $this->matched;
+ }
+
+ /**
+ * Set matched flag.
+ */
+ public function setMatch()
+ {
+ $this->matched = true;
+ return $this;
+ }
+
+ /**
+ * Retrieve the Payload.
+ */
+ public function getPayload()
+ {
+ if ($this->payload === null) {
+ $this->payload = new Payload;
+ }
+
+ return $this->payload;
+ }
+
+ /**
+ * Method to actually test for a match.
+ *
+ * If a match is found, $this->matched should be set to true
+ * and the payload needs to be instantiated to contain the relevent
+ * matched data.
+ *
+ * @param \Proem\IO\Url $url
+ * @param array $options Options dependent on your implementation.
+ */
+ abstract public function process($uri);
+}
Oops, something went wrong.

0 comments on commit 8177e89

Please sign in to comment.