From a65fa4972a657db74063dc501a80aebdf25c7bd3 Mon Sep 17 00:00:00 2001 From: Andreas Schleifer Date: Tue, 27 Jan 2015 10:56:33 +0100 Subject: [PATCH] fix more occurances of 'ressource' --- README.md | 34 +++++++++++-------- .../V1/{Ressource => Resource}/Dummy.php | 6 ++-- generator/skeleton/www/index.php | 4 +-- src/SlimBootstrap/DataObject.php | 16 ++++----- src/SlimBootstrap/Endpoint/Index.php | 2 +- 5 files changed, 33 insertions(+), 29 deletions(-) rename generator/skeleton/include/###NAMESPACE###/Endpoint/V1/{Ressource => Resource}/Dummy.php (83%) diff --git a/README.md b/README.md index c845550..4c37796 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ In order to create a rest api based on this framework you need a structure simil │ └── V1 │ ├── Collection │ │ └── EndpointA.php - │ └── Ressource + │ └── Resource │ └── EndpointA.php └── www └── index.php @@ -109,15 +109,17 @@ $bootstrap = new \SlimBootstrap\Bootstrap( $applicationConfig ); $bootstrap->init(); -$bootstrap->addRessourceGetEndpoint( +$bootstrap->addResourceEndpoint( + \SlimBootstrap\Bootstrap::HTTP_METHOD_GET, '/dummy/:name', 'dummy', array( 'name' => '\w+', ), - new \DummyApi\Endpoint\Ressource\Dummy() + new \DummyApi\Endpoint\Resource\Dummy() ); -$bootstrap->addCollectionGetEndpoint( +$bootstrap->addCollectionEndpoint( + \SlimBootstrap\Bootstrap::HTTP_METHOD_GET, '/dummy', 'dummy', new \DummyApi\Endpoint\Collection\Dummy() @@ -127,15 +129,15 @@ $bootstrap->run(); ## Create Endpoints ### Collection Endpoint -The framework supports two types of endpoints. Collection endpoints, to return multiple results and ressource endpoints to return / handle a special result. +The framework supports two types of endpoints. Collection endpoints, to return multiple results and resource endpoints to return / handle a special result. **Collection endpoints** These endpoints should implement one of the _CollectionEndpoint_ interfaces located under [\SlimBootstrap\Endpoint](src/SlimBootstrap/Endpoint). It will then get an array of filter parameters which can be passed as GET parameters and if it is not a GET endpoint an array of data which will be the payload send with the request. The endpoint should return an array of [\SlimBootstrap\DataObject](src/SlimBootstrap/DataObject.php) where each DataObject holds one result. -**Ressource endpoints** +**Resource endpoints** -These endpoints should implement one of the _RessourceEndpoint_ interfaces located under [\SlimBootstrap\Endpoint](src/SlimBootstrap/Endpoint). It will then get an array of the parameters in the URL the ressource is identified with and if it is not a GET endpoint an array of data which will be the payload send with the request. The endpoint should return a [\SlimBootstrap\DataObject](src/SlimBootstrap/DataObject.php) and it should throw a [\SlimBootstrap\Exception](src/SlimBootstrap/Exception.php) if the endpoint encounters an error. The message of that exception will be printed out as result and the code will be used as HTTP status code. +These endpoints should implement one of the _RessurceEndpoint_ interfaces located under [\SlimBootstrap\Endpoint](src/SlimBootstrap/Endpoint). It will then get an array of the parameters in the URL the resource is identified with and if it is not a GET endpoint an array of data which will be the payload send with the request. The endpoint should return a [\SlimBootstrap\DataObject](src/SlimBootstrap/DataObject.php) and it should throw a [\SlimBootstrap\Exception](src/SlimBootstrap/Exception.php) if the endpoint encounters an error. The message of that exception will be printed out as result and the code will be used as HTTP status code. ### Supported HTTP methods At the moment the framework supports the following HTTP methods: @@ -144,18 +146,18 @@ At the moment the framework supports the following HTTP methods: - POST - PUT -For each of these methods the framework supplies two interfaces for the Collection and Ressource endpoint under [\SlimBootstrap\Endpoint](src/SlimBootstrap/Endpoint). +For each of these methods the framework supplies two interfaces for the Collection and Resource endpoint under [\SlimBootstrap\Endpoint](src/SlimBootstrap/Endpoint). ### Registering endpoints to the framework The written endpoints have to be registered to the framework and the underling Slim instance in order to be accessible. This can be done by calling the appropriate add methods on the [\SlimBootstrap\Bootstrap](src/SlimBootstrap/Bootstrap.php) instance after the `init()` call and before the `run()` call. The framework is using the basic form of slim to [register a route](http://docs.slimframework.com/#Routing-Overview) and bind an endpoint to the route. In order to do this the methods need some specific parameters which are explained here for the GET endpoints but are very similar for the other endpoints: -**addCollectionGetEndpoint** +**addCollectionEndpoint** -This methods needs a `route` which is the relativ url it can be called as so for example "/myendpoint". As second argument it needs a `name` which will be used to identify the route and which can then be used in the ACL config to configure access to this route / endpoint. The third parameter is an instance of [SlimBootstrap\Endpoint\CollectionGet](src/SlimBootstrap/Endpoint/CollectionGet.php). +This methods needs a HTTP protocol for which this endpoint should be registered. This should be one of the `\SlimBootstrap\Bootstrap::HTTP_METHOD_*` constatnts. As second argument it needs a `route` which is the relativ url it can be called as so for example "/myendpoint". As third argument it needs a `name` which will be used to identify the route and which can then be used in the ACL config to configure access to this route / endpoint. The fourth parameter is an instance of [SlimBootstrap\Endpoint\Collection*](src/SlimBootstrap/Endpoint/). -**addRessourceGetEndpoint** +**addResourceEndpoint** -This methods needs a `route` which is the relativ url it can be called as so for example "/myendpoint/:someId". As second argument it needs a `name` which will be used to identify the route and which can then be used in the ACL config to configure access to this route / endpoint. The third parameter is an array of conditions that can define constrains for the passed id (`someId`). These constrains are normal PHP regular expressions. Finally the fourth parameter is an instance of [SlimBootstrap\Endpoint\RessourceGet](src/SlimBootstrap/Endpoint/RessourceGet.php). +This methods needs a HTTP protocol for which this endpoint should be registered. This should be one of the `\SlimBootstrap\Bootstrap::HTTP_METHOD_*` constatnts. As second argument it needs a `route` which is the relativ url it can be called as so for example "/myendpoint/:someId". As third argument it needs a `name` which will be used to identify the route and which can then be used in the ACL config to configure access to this route / endpoint. The fourth parameter is an array of conditions that can define constrains for the passed id (`someId`). These constrains are normal PHP regular expressions. Finally the fifth parameter is an instance of [SlimBootstrap\Endpoint\Resource*](src/SlimBootstrap/Endpoint/). ## Response Output @@ -230,15 +232,17 @@ $bootstrap = new \SlimBootstrap\Bootstrap( + $aclConfig ); $bootstrap->init(); -$bootstrap->addRessourceGetEndpoint( +$bootstrap->addResourceEndpoint( + \SlimBootstrap\Bootstrap::HTTP_METHOD_GET, '/dummy/:name', 'dummy', array( 'name' => '\w+', ), - new \DummyApi\Endpoint\Ressource\Dummy() + new \DummyApi\Endpoint\Resource\Dummy() ); -$bootstrap->addCollectionGetEndpoint( +$bootstrap->addCollectionEndpoint( + \SlimBootstrap\Bootstrap::HTTP_METHOD_GET, '/dummy', 'dummy', new \DummyApi\Endpoint\Collection\Dummy() diff --git a/generator/skeleton/include/###NAMESPACE###/Endpoint/V1/Ressource/Dummy.php b/generator/skeleton/include/###NAMESPACE###/Endpoint/V1/Resource/Dummy.php similarity index 83% rename from generator/skeleton/include/###NAMESPACE###/Endpoint/V1/Ressource/Dummy.php rename to generator/skeleton/include/###NAMESPACE###/Endpoint/V1/Resource/Dummy.php index dcf32b4..b0b340e 100644 --- a/generator/skeleton/include/###NAMESPACE###/Endpoint/V1/Ressource/Dummy.php +++ b/generator/skeleton/include/###NAMESPACE###/Endpoint/V1/Resource/Dummy.php @@ -1,5 +1,5 @@ init(); // --- V1 Endpoints - begin --- -$bootstrap->addRessourceEndpoint( +$bootstrap->addResourceEndpoint( \SlimBootstrap\Bootstrap::HTTP_METHOD_GET, '/v1/dummy/:dummyId', 'dummy', array( 'dummyId' => '\\d+', ), - new \###NAMESPACE###\Endpoint\V1\Ressource\Dummy() + new \###NAMESPACE###\Endpoint\V1\Resource\Dummy() ); $bootstrap->addCollectionEndpoint( \SlimBootstrap\Bootstrap::HTTP_METHOD_GET, diff --git a/src/SlimBootstrap/DataObject.php b/src/SlimBootstrap/DataObject.php index 4e8fc12..908b6b4 100644 --- a/src/SlimBootstrap/DataObject.php +++ b/src/SlimBootstrap/DataObject.php @@ -3,15 +3,15 @@ /** * This class represents a result set for the endpoints. - * One instance represents a HAL+JSON ressource for one specific embedded - * ressource. + * One instance represents a HAL+JSON resource for one specific embedded + * resource. * * @package SlimBootstrap */ class DataObject { /** - * The identifiers to show in the HAL+JSON output how this ressource is + * The identifiers to show in the HAL+JSON output how this resource is * identified. * * @var array @@ -26,7 +26,7 @@ class DataObject private $_data = array(); /** - * The links to show in the HAL+JSON output for this ressource. + * The links to show in the HAL+JSON output for this resource. * * @var array */ @@ -36,7 +36,7 @@ class DataObject * @param array $identifiers The identifiers to show in the HAL+JSON output. * @param array $data The actual data to pass to the output. * @param array $links The links to show in the HAL+JSON output for - * this ressource. + * this resource. */ public function __construct( array $identifiers, @@ -49,7 +49,7 @@ public function __construct( } /** - * Returns the HAL+JSON identifiers for this ressource. + * Returns the HAL+JSON identifiers for this resource. * * @return array */ @@ -59,7 +59,7 @@ public function getIdentifiers() } /** - * Returns the actual payload of this ressource. + * Returns the actual payload of this resource. * * @return array */ @@ -69,7 +69,7 @@ public function getData() } /** - * Returns the links for this HAL+JSON ressource. + * Returns the links for this HAL+JSON resource. * * @return array */ diff --git a/src/SlimBootstrap/Endpoint/Index.php b/src/SlimBootstrap/Endpoint/Index.php index dd98eb6..0278c76 100644 --- a/src/SlimBootstrap/Endpoint/Index.php +++ b/src/SlimBootstrap/Endpoint/Index.php @@ -26,7 +26,7 @@ public function __construct(array $endpoints) } /** - * This function creates a ressource that has links to all existing + * This function creates a resource that has links to all existing * endpoints. * * @return SlimBootstrap\DataObject