mirror of
https://github.com/silverstripe/silverstripe-restfulserver
synced 2024-10-22 14:05:58 +02:00
Silence Travis CI complaints about Versioned via require-dev
This commit is contained in:
parent
6601b42c4b
commit
3dda824796
@ -27,7 +27,7 @@ before_script:
|
|||||||
script:
|
script:
|
||||||
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
|
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
|
||||||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
|
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
|
||||||
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=vendor/silverstripe/framework/phpcs.xml.dist code/ tests/; fi
|
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/ *.php; fi
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi
|
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi
|
||||||
|
@ -9,7 +9,7 @@ mappings:
|
|||||||
RestfulServerTestComment: SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestComment
|
RestfulServerTestComment: SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestComment
|
||||||
RestfulServerTestPage: SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestPage
|
RestfulServerTestPage: SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestPage
|
||||||
RestfulServerTestSecretThing: SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestSecretThing
|
RestfulServerTestSecretThing: SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestSecretThing
|
||||||
DataFormatter: SilverStripe\RestfulServer\DataFormatter\DataFormatter
|
DataFormatter: SilverStripe\RestfulServer\DataFormatter
|
||||||
FormEncodedDataFormatter: SilverStripe\RestfulServer\DataFormatter\FormEncodedDataFormatter
|
FormEncodedDataFormatter: SilverStripe\RestfulServer\DataFormatter\FormEncodedDataFormatter
|
||||||
JSONDataFormatter: SilverStripe\RestfulServer\DataFormatter\JSONDataFormatter
|
JSONDataFormatter: SilverStripe\RestfulServer\DataFormatter\JSONDataFormatter
|
||||||
XMLDataFormatter: SilverStripe\RestfulServer\DataFormatter\XMLDataFormatter
|
XMLDataFormatter: SilverStripe\RestfulServer\DataFormatter\XMLDataFormatter
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/PHPUnit": "^5.7",
|
"phpunit/PHPUnit": "^5.7",
|
||||||
"squizlabs/php_codesniffer": "^3.0"
|
"squizlabs/php_codesniffer": "^3.0",
|
||||||
|
"silverstripe/versioned": "^1"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
</testsuite>
|
</testsuite>
|
||||||
<filter>
|
<filter>
|
||||||
<whitelist addUncoveredFilesFromWhitelist="true">
|
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||||
<directory suffix=".php">code/</directory>
|
<directory suffix=".php">src/</directory>
|
||||||
<exclude>
|
<exclude>
|
||||||
<directory suffix=".php">tests/</directory>
|
<directory suffix=".php">tests/</directory>
|
||||||
</exclude>
|
</exclude>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\RestfulServer\DataFormatter;
|
namespace SilverStripe\RestfulServer;
|
||||||
|
|
||||||
use SilverStripe\Core\ClassInfo;
|
use SilverStripe\Core\ClassInfo;
|
||||||
use SilverStripe\Core\Config\Configurable;
|
use SilverStripe\Core\Config\Configurable;
|
||||||
@ -11,9 +11,6 @@ use SilverStripe\ORM\SS_List;
|
|||||||
/**
|
/**
|
||||||
* A DataFormatter object handles transformation of data from SilverStripe model objects to a particular output
|
* A DataFormatter object handles transformation of data from SilverStripe model objects to a particular output
|
||||||
* format, and vice versa. This is most commonly used in developing RESTful APIs.
|
* format, and vice versa. This is most commonly used in developing RESTful APIs.
|
||||||
*
|
|
||||||
* @package framework
|
|
||||||
* @subpackage formatters
|
|
||||||
*/
|
*/
|
||||||
abstract class DataFormatter
|
abstract class DataFormatter
|
||||||
{
|
{
|
@ -15,9 +15,6 @@ namespace SilverStripe\RestfulServer\DataFormatter;
|
|||||||
* @todo Format response form encoded as well - currently uses XMLDataFormatter
|
* @todo Format response form encoded as well - currently uses XMLDataFormatter
|
||||||
*
|
*
|
||||||
* @author Cam Spiers <camspiers at gmail dot com>
|
* @author Cam Spiers <camspiers at gmail dot com>
|
||||||
*
|
|
||||||
* @package framework
|
|
||||||
* @subpackage formatters
|
|
||||||
*/
|
*/
|
||||||
class FormEncodedDataFormatter extends XMLDataFormatter
|
class FormEncodedDataFormatter extends XMLDataFormatter
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\RestfulServer\DataFormatter;
|
namespace SilverStripe\RestfulServer\DataFormatter;
|
||||||
|
|
||||||
|
use SilverStripe\RestfulServer\DataFormatter;
|
||||||
use SilverStripe\ORM\DataObjectInterface;
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
use SilverStripe\View\ArrayData;
|
use SilverStripe\View\ArrayData;
|
||||||
@ -9,8 +10,7 @@ use SilverStripe\Control\Director;
|
|||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* Formats a DataObject's member fields into a JSON string
|
||||||
* @subpackage formatters
|
|
||||||
*/
|
*/
|
||||||
class JSONDataFormatter extends DataFormatter
|
class JSONDataFormatter extends DataFormatter
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\RestfulServer\DataFormatter;
|
namespace SilverStripe\RestfulServer\DataFormatter;
|
||||||
|
|
||||||
|
use SilverStripe\RestfulServer\DataFormatter;
|
||||||
use SilverStripe\ORM\DataObjectInterface;
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
@ -10,8 +11,7 @@ use SilverStripe\Core\Convert;
|
|||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* Formats a DataObject's member fields into an XML string
|
||||||
* @subpackage formatters
|
|
||||||
*/
|
*/
|
||||||
class XMLDataFormatter extends DataFormatter
|
class XMLDataFormatter extends DataFormatter
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ use SilverStripe\ORM\DataList;
|
|||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\RestfulServer\DataFormatter\DataFormatter;
|
use SilverStripe\RestfulServer\DataFormatter;
|
||||||
use SilverStripe\Control\HTTPRequest;
|
use SilverStripe\Control\HTTPRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +20,6 @@ use SilverStripe\Control\HTTPRequest;
|
|||||||
* Relies on serialization/deserialization into different formats provided
|
* Relies on serialization/deserialization into different formats provided
|
||||||
* by the DataFormatter APIs in core.
|
* by the DataFormatter APIs in core.
|
||||||
*
|
*
|
||||||
* @todo Finish RestfulServerItem and RestfulServerList implementation and re-enable $url_handlers
|
|
||||||
* @todo Implement PUT/POST/DELETE for relations
|
* @todo Implement PUT/POST/DELETE for relations
|
||||||
* @todo Access-Control for relations (you might be allowed to view Members and Groups,
|
* @todo Access-Control for relations (you might be allowed to view Members and Groups,
|
||||||
* but not their relation with each other)
|
* but not their relation with each other)
|
||||||
@ -38,21 +37,24 @@ use SilverStripe\Control\HTTPRequest;
|
|||||||
* @todo i18n integration (e.g. Page/1.xml?lang=de_DE)
|
* @todo i18n integration (e.g. Page/1.xml?lang=de_DE)
|
||||||
* @todo Access to extendable methods/relations like SiteTree/1/Versions or SiteTree/1/Version/22
|
* @todo Access to extendable methods/relations like SiteTree/1/Versions or SiteTree/1/Version/22
|
||||||
* @todo Respect $api_access array notation in search contexts
|
* @todo Respect $api_access array notation in search contexts
|
||||||
*
|
|
||||||
* @package framework
|
|
||||||
* @subpackage api
|
|
||||||
*/
|
*/
|
||||||
class RestfulServer extends Controller
|
class RestfulServer extends Controller
|
||||||
{
|
{
|
||||||
private static $url_handlers = array(
|
private static $url_handlers = array(
|
||||||
'$ClassName!/$ID/$Relation' => 'handleAction',
|
'$ClassName!/$ID/$Relation' => 'handleAction',
|
||||||
'' => 'notFound'
|
'' => 'notFound'
|
||||||
#'$ClassName/#ID' => 'handleItem',
|
|
||||||
#'$ClassName' => 'handleList',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @config
|
||||||
|
* @var string root of the api route, MUST have a trailing slash
|
||||||
|
*/
|
||||||
private static $api_base = "api/v1/";
|
private static $api_base = "api/v1/";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @config
|
||||||
|
* @var string Class name for an authenticator to use on API access
|
||||||
|
*/
|
||||||
private static $authenticator = BasicRestfulAuthenticator::class;
|
private static $authenticator = BasicRestfulAuthenticator::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,16 +83,6 @@ class RestfulServer extends Controller
|
|||||||
'notFound'
|
'notFound'
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
function handleItem($request) {
|
|
||||||
return new RestfulServerItem(DataObject::get_by_id($request->param("ClassName"), $request->param("ID")));
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleList($request) {
|
|
||||||
return new RestfulServerList(DataObject::get($request->param("ClassName"),""));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
/* This sets up SiteTree the same as when viewing a page through the frontend. Versioned defaults
|
/* This sets up SiteTree the same as when viewing a page through the frontend. Versioned defaults
|
||||||
@ -470,7 +462,8 @@ class RestfulServer extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$urlSafeClassName = $this->sanitiseClassName(get_class($obj));
|
$urlSafeClassName = $this->sanitiseClassName(get_class($obj));
|
||||||
$objHref = Director::absoluteURL(self::$api_base . "$urlSafeClassName/$obj->ID" . $type);
|
$apiBase = $this->config()->api_base;
|
||||||
|
$objHref = Director::absoluteURL($apiBase . "$urlSafeClassName/$obj->ID" . $type);
|
||||||
$this->getResponse()->addHeader('Location', $objHref);
|
$this->getResponse()->addHeader('Location', $objHref);
|
||||||
|
|
||||||
return $responseFormatter->convertDataObject($obj);
|
return $responseFormatter->convertDataObject($obj);
|
||||||
@ -540,7 +533,8 @@ class RestfulServer extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$urlSafeClassName = $this->sanitiseClassName(get_class($obj));
|
$urlSafeClassName = $this->sanitiseClassName(get_class($obj));
|
||||||
$objHref = Director::absoluteURL(self::$api_base . "$urlSafeClassName/$obj->ID" . $type);
|
$apiBase = $this->config()->api_base;
|
||||||
|
$objHref = Director::absoluteURL($apiBase . "$urlSafeClassName/$obj->ID" . $type);
|
||||||
$this->getResponse()->addHeader('Location', $objHref);
|
$this->getResponse()->addHeader('Location', $objHref);
|
||||||
|
|
||||||
return $responseFormatter->convertDataObject($obj);
|
return $responseFormatter->convertDataObject($obj);
|
||||||
|
@ -6,9 +6,6 @@ use SilverStripe\ORM\SS_List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Restful server handler for a single DataObject
|
* Restful server handler for a single DataObject
|
||||||
*
|
|
||||||
* @package framework
|
|
||||||
* @subpackage api
|
|
||||||
*/
|
*/
|
||||||
class RestfulServerItem
|
class RestfulServerItem
|
||||||
{
|
{
|
||||||
|
@ -4,9 +4,6 @@ namespace SilverStripe\RestfulServer;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Restful server handler for a SS_List
|
* Restful server handler for a SS_List
|
||||||
*
|
|
||||||
* @package framework
|
|
||||||
* @subpackage api
|
|
||||||
*/
|
*/
|
||||||
class RestfulServerList
|
class RestfulServerList
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,9 @@ SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthor:
|
|||||||
Firstname: Author 3
|
Firstname: Author 3
|
||||||
author4:
|
author4:
|
||||||
FirstName: Author 4
|
FirstName: Author 4
|
||||||
RelatedAuthors: =>SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthor.author2,=>SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthor.author3
|
RelatedAuthors:
|
||||||
|
- =>SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthor.author2
|
||||||
|
- =>SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthor.author3
|
||||||
SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthorRating:
|
SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthorRating:
|
||||||
rating1:
|
rating1:
|
||||||
Rating: 3
|
Rating: 3
|
Loading…
Reference in New Issue
Block a user