git-svn-id: https://msi/svn/firstRepo/Service/branches/Slim3@40 0f545695-f87b-41b6-9a03-7f16563b5454

This commit is contained in:
2016-01-05 21:43:12 +00:00
parent 4318dd829f
commit 00d78a2ba8
46 changed files with 4960 additions and 32 deletions
@@ -0,0 +1,27 @@
<?php
/**
* Slim Framework (http://slimframework.com)
*
* @link https://github.com/slimphp/Slim
* @copyright Copyright (c) 2011-2015 Josh Lockhart
* @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License)
*/
namespace Slim\Interfaces;
/**
* Resolves a callable.
*
* @package Slim
* @since 3.0.0
*/
interface CallableResolverInterface
{
/**
* Invoke the resolved callable.
*
* @param mixed $toResolve
*
* @return callable
*/
public function resolve($toResolve);
}
+32
View File
@@ -0,0 +1,32 @@
<?php
/**
* Slim Framework (http://slimframework.com)
*
* @link https://github.com/slimphp/Slim
* @copyright Copyright (c) 2011-2015 Josh Lockhart
* @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License)
*/
namespace Slim\Interfaces;
/**
* Collection Interface
*
* @package Slim
* @since 3.0.0
*/
interface CollectionInterface extends \ArrayAccess, \Countable, \IteratorAggregate
{
public function set($key, $value);
public function get($key, $default = null);
public function replace(array $items);
public function all();
public function has($key);
public function remove($key);
public function clear();
}
+23
View File
@@ -0,0 +1,23 @@
<?php
/**
* Slim Framework (http://slimframework.com)
*
* @link https://github.com/slimphp/Slim
* @copyright Copyright (c) 2011-2015 Josh Lockhart
* @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License)
*/
namespace Slim\Interfaces\Http;
/**
* Cookies Interface
*
* @package Slim
* @since 3.0.0
*/
interface CookiesInterface
{
public function get($name, $default = null);
public function set($name, $value);
public function toHeaders();
public static function parseHeader($header);
}
@@ -0,0 +1,20 @@
<?php
/**
* Slim Framework (http://slimframework.com)
*
* @link https://github.com/slimphp/Slim
* @copyright Copyright (c) 2011-2015 Josh Lockhart
* @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License)
*/
namespace Slim\Interfaces\Http;
/**
* Environment Interface
*
* @package Slim
* @since 3.0.0
*/
interface EnvironmentInterface
{
public static function mock(array $settings = []);
}
+24
View File
@@ -0,0 +1,24 @@
<?php
/**
* Slim Framework (http://slimframework.com)
*
* @link https://github.com/slimphp/Slim
* @copyright Copyright (c) 2011-2015 Josh Lockhart
* @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License)
*/
namespace Slim\Interfaces\Http;
use Slim\Interfaces\CollectionInterface;
/**
* Headers Interface
*
* @package Slim
* @since 3.0.0
*/
interface HeadersInterface extends CollectionInterface
{
public function add($key, $value);
public function normalizeKey($key);
}
@@ -0,0 +1,30 @@
<?php
/**
* Slim Framework (http://slimframework.com)
*
* @link https://github.com/slimphp/Slim
* @copyright Copyright (c) 2011-2015 Josh Lockhart
* @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License)
*/
namespace Slim\Interfaces;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
/**
* Defines a contract for invoking a route callable.
*/
interface InvocationStrategyInterface
{
/**
* Invoke a route callable.
*
* @param callable $callable The callable to invoke using the strategy.
* @param ServerRequestInterface $request The request object.
* @param ResponseInterface $response The response object.
* @param array $routeArguments The route's placholder arguments
*
* @return ResponseInterface|string The response from the callable.
*/
public function __invoke(callable $callable, ServerRequestInterface $request, ResponseInterface $response, array $routeArguments);
}
+46
View File
@@ -0,0 +1,46 @@
<?php
/**
* Slim Framework (http://slimframework.com)
*
* @link https://github.com/slimphp/Slim
* @copyright Copyright (c) 2011-2015 Josh Lockhart
* @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License)
*/
namespace Slim\Interfaces;
use Slim\App;
/**
* RouteGroup Interface
*
* @package Slim
* @since 3.0.0
*/
interface RouteGroupInterface
{
/**
* Get route pattern
*
* @return string
*/
public function getPattern();
/**
* Prepend middleware to the group middleware collection
*
* @param mixed $callable The callback routine
*
* @return RouteGroupInterface
*/
public function add($callable);
/**
* Execute route group callable in the context of the Slim App
*
* This method invokes the route group object's callable, collecting
* nested route objects
*
* @param App $app
*/
public function __invoke(App $app);
}
+129
View File
@@ -0,0 +1,129 @@
<?php
/**
* Slim Framework (http://slimframework.com)
*
* @link https://github.com/slimphp/Slim
* @copyright Copyright (c) 2011-2015 Josh Lockhart
* @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License)
*/
namespace Slim\Interfaces;
use InvalidArgumentException;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
/**
* Route Interface
*
* @package Slim
* @since 3.0.0
*/
interface RouteInterface
{
/**
* Retrieve a specific route argument
*
* @param string $name
* @param mixed $default
*
* @return mixed
*/
public function getArgument($name, $default = null);
/**
* Get route arguments
*
* @return array
*/
public function getArguments();
/**
* Get route name
*
* @return null|string
*/
public function getName();
/**
* Get route pattern
*
* @return string
*/
public function getPattern();
/**
* Set a route argument
*
* @param string $name
* @param string $value
*
* @return static
*/
public function setArgument($name, $value);
/**
* Replace route arguments
*
* @param array $arguments
*
* @return static
*/
public function setArguments(array $arguments);
/**
* Set route name
*
* @param string $name
*
* @return static
* @throws InvalidArgumentException if the route name is not a string
*/
public function setName($name);
/**
* Add middleware
*
* This method prepends new middleware to the route's middleware stack.
*
* @param mixed $callable The callback routine
*
* @return RouteInterface
*/
public function add($callable);
/**
* Prepare the route for use
*
* @param ServerRequestInterface $request
* @param array $arguments
*/
public function prepare(ServerRequestInterface $request, array $arguments);
/**
* Run route
*
* This method traverses the middleware stack, including the route's callable
* and captures the resultant HTTP response object. It then sends the response
* back to the Application.
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function run(ServerRequestInterface $request, ResponseInterface $response);
/**
* Dispatch route callable against current Request and Response objects
*
* This method invokes the route object's callable. If middleware is
* registered for the route, each callable middleware is invoked in
* the order specified.
*
* @param ServerRequestInterface $request The current Request object
* @param ResponseInterface $response The current Response object
*
* @return ResponseInterface
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response);
}
+107
View File
@@ -0,0 +1,107 @@
<?php
/**
* Slim Framework (http://slimframework.com)
*
* @link https://github.com/slimphp/Slim
* @copyright Copyright (c) 2011-2015 Josh Lockhart
* @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License)
*/
namespace Slim\Interfaces;
use RuntimeException;
use InvalidArgumentException;
use Psr\Http\Message\ServerRequestInterface;
/**
* Router Interface
*
* @package Slim
* @since 3.0.0
*/
interface RouterInterface
{
/**
* Add route
*
* @param string[] $methods Array of HTTP methods
* @param string $pattern The route pattern
* @param callable $handler The route callable
*
* @return RouteInterface
*/
public function map($methods, $pattern, $handler);
/**
* Dispatch router for HTTP request
*
* @param ServerRequestInterface $request The current HTTP request object
*
* @return array
*
* @link https://github.com/nikic/FastRoute/blob/master/src/Dispatcher.php
*/
public function dispatch(ServerRequestInterface $request);
/**
* Add a route group to the array
*
* @param string $pattern The group pattern
* @param callable $callable A group callable
*
* @return RouteGroupInterface
*/
public function pushGroup($pattern, $callable);
/**
* Removes the last route group from the array
*
* @return bool True if successful, else False
*/
public function popGroup();
/**
* Get named route object
*
* @param string $name Route name
*
* @return \Slim\Interfaces\RouteInterface
*
* @throws RuntimeException If named route does not exist
*/
public function getNamedRoute($name);
/**
* @param $identifier
*
* @return \Slim\Interfaces\RouteInterface
*/
public function lookupRoute($identifier);
/**
* Build the path for a named route excluding the base path
*
* @param string $name Route name
* @param array $data Named argument replacement data
* @param array $queryParams Optional query string parameters
*
* @return string
*
* @throws RuntimeException If named route does not exist
* @throws InvalidArgumentException If required data not provided
*/
public function relativePathFor($name, array $data = [], array $queryParams = []);
/**
* Build the path for a named route including the base path
*
* @param string $name Route name
* @param array $data Named argument replacement data
* @param array $queryParams Optional query string parameters
*
* @return string
*
* @throws RuntimeException If named route does not exist
* @throws InvalidArgumentException If required data not provided
*/
public function pathFor($name, array $data = [], array $queryParams = []);
}