mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Rename SS_ prefixed classes (#5974)
This commit is contained in:
parent
f5d71dc8ec
commit
bfd9cb1aca
77
.upgrade.yml
77
.upgrade.yml
@ -12,20 +12,26 @@ mappings:
|
||||
DataQuery: SilverStripe\ORM\DataQuery
|
||||
DataQuery_SubGroup: SilverStripe\ORM\DataQuery_SubGroup
|
||||
DB: SilverStripe\ORM\DB
|
||||
SS_Filterable: SilverStripe\ORM\SS_Filterable
|
||||
SS_Filterable: SilverStripe\ORM\Filterable
|
||||
SilverStripe\ORM\SS_Filterable: SilverStripe\ORM\Filterable
|
||||
GroupedList: SilverStripe\ORM\GroupedList
|
||||
HasManyList: SilverStripe\ORM\HasManyList
|
||||
HiddenClass: SilverStripe\ORM\HiddenClass
|
||||
SS_Limitable: SilverStripe\ORM\SS_Limitable
|
||||
SS_Limitable: SilverStripe\ORM\Limitable
|
||||
SilverStripe\ORM\SS_Limitable: SilverStripe\ORM\Limitable
|
||||
SS_List: SilverStripe\ORM\SS_List
|
||||
SS_ListDecorator: SilverStripe\ORM\SS_ListDecorator
|
||||
SS_ListDecorator: SilverStripe\ORM\ListDecorator
|
||||
SilverStripe\ORM\SS_ListDecorator: SilverStripe\ORM\ListDecorator
|
||||
ManyManyList: SilverStripe\ORM\ManyManyList
|
||||
SS_Map: SilverStripe\ORM\SS_Map
|
||||
SS_Map_Iterator: SilverStripe\ORM\SS_Map_Iterator
|
||||
SS_Map: SilverStripe\ORM\Map
|
||||
SilverStripe\ORM\SS_Map: SilverStripe\ORM\Map
|
||||
SS_Map_Iterator: SilverStripe\ORM\Map_Iterator
|
||||
SilverStripe\ORM\SS_Map_Iterator: SilverStripe\ORM\Map_Iterator
|
||||
PolymorphicHasManyList: SilverStripe\ORM\PolymorphicHasManyList
|
||||
SilverStripe\Model\Relation: SilverStripe\ORM\Relation
|
||||
RelationList: SilverStripe\ORM\RelationList
|
||||
SS_Sortable: SilverStripe\ORM\SS_Sortable
|
||||
SS_Sortable: SilverStripe\ORM\Sortable
|
||||
SilverStripe\ORM\SS_Sortable: SilverStripe\ORM\Sortable
|
||||
UnsavedRelationList: SilverStripe\ORM\UnsavedRelationList
|
||||
ValidationException: SilverStripe\ORM\ValidationException
|
||||
ValidationResult: SilverStripe\ORM\ValidationResult
|
||||
@ -38,8 +44,10 @@ mappings:
|
||||
SQLSelect: SilverStripe\ORM\Queries\SQLSelect
|
||||
SQLUpdate: SilverStripe\ORM\Queries\SQLUpdate
|
||||
SQLWriteExpression: SilverStripe\ORM\Queries\SQLWriteExpression
|
||||
SS_Database: SilverStripe\ORM\Connect\SS_Database
|
||||
SS_DatabaseException: SilverStripe\ORM\Connect\SS_DatabaseException
|
||||
SS_Database: SilverStripe\ORM\Connect\Database
|
||||
SS_DatabaseException: SilverStripe\ORM\Connect\DatabaseException
|
||||
SilverStripe\ORM\Connect\SS_Database: SilverStripe\ORM\Connect\Database
|
||||
SilverStripe\ORM\Connect\SS_DatabaseException: SilverStripe\ORM\Connect\DatabaseException
|
||||
DBConnector: SilverStripe\ORM\Connect\DBConnector
|
||||
DBQueryBuilder: SilverStripe\ORM\Connect\DBQueryBuilder
|
||||
DBSchemaManager: SilverStripe\ORM\Connect\DBSchemaManager
|
||||
@ -51,7 +59,8 @@ mappings:
|
||||
MySQLStatement: SilverStripe\ORM\Connect\MySQLStatement
|
||||
PDOConnector: SilverStripe\ORM\Connect\PDOConnector
|
||||
PDOQuery: SilverStripe\ORM\Connect\PDOQuery
|
||||
SS_Query: SilverStripe\ORM\Connect\SS_Query
|
||||
SS_Query: SilverStripe\ORM\Connect\Query
|
||||
SilverStripe\ORM\Connect\SS_Query: SilverStripe\ORM\Connect\Query
|
||||
DBBoolean: SilverStripe\ORM\FieldType\DBBoolean
|
||||
DBClassName: SilverStripe\ORM\FieldType\DBClassName
|
||||
DBComposite: SilverStripe\ORM\FieldType\DBComposite
|
||||
@ -193,7 +202,8 @@ mappings:
|
||||
SilverStripe\Filesystem\Thumbnail: SilverStripe\Assets\Thumbnail
|
||||
SilverStripe\Filesystem\ImageManipulation: SilverStripe\Assets\ImageManipulation
|
||||
File: SilverStripe\Assets\File
|
||||
SS_FileFinder: SilverStripe\Assets\SS_FileFinder
|
||||
SS_FileFinder: SilverStripe\Assets\FileFinder
|
||||
SilverStripe\Assets\SS_FileFinder: SilverStripe\Assets\FileFinder
|
||||
FileMigrationHelper: SilverStripe\Assets\FileMigrationHelper
|
||||
FileNameFilter: SilverStripe\Assets\FileNameFilter
|
||||
Filesystem: SilverStripe\Assets\Filesystem
|
||||
@ -207,13 +217,17 @@ mappings:
|
||||
SilverStripe\Framework\Core\Configurable: SilverStripe\Core\Config\Configurable
|
||||
PaginatedList: SilverStripe\ORM\PaginatedList
|
||||
ArrayLib: SilverStripe\ORM\ArrayLib
|
||||
SS_DAG: SilverStripe\Core\Config\SS_Dag
|
||||
SS_DAG: SilverStripe\Core\Config\Dag
|
||||
SilverStripe\Core\Config\SS_DAG: SilverStripe\Core\Config\Dag
|
||||
SS_DAG_CyclicException: SilverStripe\Core\Config\SS_DAG_CyclicException
|
||||
SS_DAG_Iterator: SilverStripe\Core\Config\SS_Dag_Iterator
|
||||
SilverStripe\Core\Config\SS_DAG_CyclicException: SilverStripe\Core\Config\DAG_CyclicException
|
||||
SS_DAG_Iterator: SilverStripe\Core\Config\Dag_Iterator
|
||||
SilverStripe\Core\Config\SS_DAG_Iterator: SilverStripe\Core\Config\Dag_Iterator
|
||||
SilverStripe\Framework\Injector\Factory: SilverStripe\Core\Injector\Factory
|
||||
SilverStripe\Framework\Core\Extensible: SilverStripe\Core\Extensible
|
||||
SilverStripe\Framework\Core\Injectable: SilverStripe\Core\Injector\Injectable
|
||||
SS_Cache: SilverStripe\Core\SS_Cache
|
||||
SS_Cache: SilverStripe\Core\Cache
|
||||
SilverStripe\Core\SS_Cache: SilverStripe\Core\Cache
|
||||
ClassInfo: SilverStripe\Core\ClassInfo
|
||||
Convert: SilverStripe\Core\Convert
|
||||
Extension: SilverStripe\Core\Extension
|
||||
@ -230,9 +244,13 @@ mappings:
|
||||
ServiceConfigurationLocator: SilverStripe\Core\Injector\ServiceConfigurationLocator
|
||||
SilverStripeServiceConfigurationLocator: SilverStripe\Core\Injector\SilverStripeServiceConfigurationLocator
|
||||
SS_ClassLoader: SilverStripe\Core\Manifest\SS_ClassLoader
|
||||
SS_ClassManifest: SilverStripe\Core\Manifest\SS_ClassManifest
|
||||
SS_ConfigManifest: SilverStripe\Core\Manifest\SS_ConfigManifest
|
||||
SS_ConfigStaticManifest: SilverStripe\Core\Manifest\SS_ConfigStaticManifest
|
||||
SilverStripe\Core\Manifest\SS_ClassLoader: SilverStripe\Core\Manifest\ClassLoader
|
||||
SS_ClassManifest: SilverStripe\Core\Manifest\ClassManifest
|
||||
SilverStripe\Core\Manifest\SS_ClassManifest: SilverStripe\Core\Manifest\ClassManifest
|
||||
SS_ConfigManifest: SilverStripe\Core\Manifest\ConfigManifest
|
||||
SilverStripe\Core\Manifest\SS_ConfigManifest: SilverStripe\Core\Manifest\ConfigManifest
|
||||
SS_ConfigStaticManifest: SilverStripe\Core\Manifest\ConfigStaticManifest
|
||||
SilverStripe\Core\Manifest\SS_ConfigStaticManifest: SilverStripe\Core\Manifest\ConfigStaticManifest
|
||||
ManifestCache: SilverStripe\Core\Manifest\ManifestCache
|
||||
ManifestCache_File: SilverStripe\Core\Manifest\ManifestCache_File
|
||||
ManifestCache_File_PHP: SilverStripe\Core\Manifest\ManifestCache_File_PHP
|
||||
@ -244,12 +262,14 @@ mappings:
|
||||
DatabaseAdapterRegistry: SilverStripe\Dev\Install\DatabaseAdapterRegistry
|
||||
DatabaseConfigurationHelper: SilverStripe\Dev\Install\DatabaseConfigurationHelper
|
||||
MySQLDatabaseConfigurationHelper: SilverStripe\Dev\Install\MySQLDatabaseConfigurationHelper
|
||||
SS_Backtrace: SilverStripe\Dev\SS_Backtrace
|
||||
SS_Backtrace: SilverStripe\Dev\Backtrace
|
||||
SilverStripe\Dev\SS_Backtrace: SilverStripe\Dev\Backtrace
|
||||
BehatFixtureFactory: SilverStripe\Dev\BehatFixtureFactory
|
||||
BuildTask: SilverStripe\Dev\BuildTask
|
||||
BulkLoader: SilverStripe\Dev\BulkLoader
|
||||
BulkLoader_Result: SilverStripe\Dev\BulkLoader_Result
|
||||
SS_Cli: SilverStripe\Dev\SS_Cli
|
||||
SS_Cli: SilverStripe\Dev\CLI
|
||||
SilverStripe\Dev\SS_Cli: SilverStripe\Dev\CLI
|
||||
CliDebugView: SilverStripe\Dev\CliDebugView
|
||||
CliTestReporter: SilverStripe\Dev\CliTestReporter
|
||||
CSSContentParser: SilverStripe\Dev\CSSContentParser
|
||||
@ -287,9 +307,12 @@ mappings:
|
||||
Director: SilverStripe\Control\Director
|
||||
FlushRequestFilter: SilverStripe\Control\FlushRequestFilter
|
||||
HTTP: SilverStripe\Control\HTTP
|
||||
SS_HTTPRequest: SilverStripe\Control\SS_HTTPRequest
|
||||
SS_HTTPResponse: SilverStripe\Control\SS_HTTPResponse
|
||||
SS_HTTPResponse_Exception: SilverStripe\Control\SS_HTTPResponse_Exception
|
||||
SS_HTTPRequest: SilverStripe\Control\HTTPRequest
|
||||
SS_HTTPResponse: SilverStripe\Control\HTTPResponse
|
||||
SS_HTTPResponse_Exception: SilverStripe\Control\HTTPResponse_Exception
|
||||
SilverStripe\Control\SS_HTTPRequest: SilverStripe\Control\HTTPRequest
|
||||
SilverStripe\Control\SS_HTTPResponse: SilverStripe\Control\HTTPResponse
|
||||
SilverStripe\Control\SS_HTTPResponse_Exception: SilverStripe\Control\HTTPResponse_Exception
|
||||
NestedController: SilverStripe\Control\NestedController
|
||||
NullHTTPRequest: SilverStripe\Control\NullHTTPRequest
|
||||
PjaxResponseNegotiator: SilverStripe\Control\PjaxResponseNegotiator
|
||||
@ -441,7 +464,8 @@ mappings:
|
||||
SilverStripe\Framework\Logging\DetailedErrorFormatter: SilverStripe\Logging\DetailedErrorFormatter
|
||||
SilverStripe\Framework\Logging\HTTPOutputHandler: SilverStripe\Logging\HTTPOutputHandler
|
||||
SilverStripe\Framework\Logging\MonologErrorHandler: SilverStripe\Logging\MonologErrorHandler
|
||||
SS_Log: SilverStripe\Logging\SS_Log
|
||||
SS_Log: SilverStripe\Logging\Log
|
||||
SilverStripe\Logging\SS_Log: SilverStripe\Logging\Log
|
||||
ComparisonFilter: SilverStripe\ORM\Filters\ComparisonFilter
|
||||
EndsWithFilter: SilverStripe\ORM\Filters\EndsWithFilter
|
||||
ExactMatchFilter: SilverStripe\ORM\Filters\ExactMatchFilter
|
||||
@ -476,15 +500,18 @@ mappings:
|
||||
ViewableData_Debugger: SilverStripe\View\ViewableData_Debugger
|
||||
BBCodeParser: SilverStripe\View\Parsers\BBCodeParser
|
||||
HTMLCleaner: SilverStripe\View\Parsers\HTMLCleaner
|
||||
SS_HTMLValue: SilverStripe\View\Parsers\SS_HTMLValue
|
||||
SS_HTML4Value: SilverStripe\View\Parsers\SS_HTML4Value
|
||||
SS_HTMLValue: SilverStripe\View\Parsers\HTMLValue
|
||||
SS_HTML4Value: SilverStripe\View\Parsers\HTML4Value
|
||||
SilverStripe\View\Parsers\SS_HTMLValue: SilverStripe\View\Parsers\HTMLValue
|
||||
SilverStripe\View\Parsers\SS_HTML4Value: SilverStripe\View\Parsers\HTML4Value
|
||||
PurifierHTMLCleaner: SilverStripe\View\Parsers\PurifierHTMLCleaner
|
||||
ShortcodeHandler: SilverStripe\View\Parsers\ShortcodeHandler
|
||||
ShortcodeParser: SilverStripe\View\Parsers\ShortcodeParser
|
||||
SQLFormatter: SilverStripe\View\Parsers\SQLFormatter
|
||||
TextParser: SilverStripe\View\Parsers\TextParser
|
||||
TidyHTMLCleaner: SilverStripe\View\Parsers\TidyHTMLCleaner
|
||||
SS_Transliterator: SilverStripe\View\Parsers\SS_Transliterator
|
||||
SS_Transliterator: SilverStripe\View\Parsers\Transliterator
|
||||
SilverStripe\View\Parsers\SS_Transliterator: SilverStripe\View\Parsers\Transliterator
|
||||
URLSegmentFilter: SilverStripe\View\Parsers\URLSegmentFilter
|
||||
skipConfigs:
|
||||
- db
|
||||
|
@ -30,7 +30,7 @@ use InvalidArgumentException;
|
||||
* - max_depth (int): The maxmium depth to traverse down the folder tree,
|
||||
* default to unlimited.
|
||||
*/
|
||||
class SS_FileFinder {
|
||||
class FileFinder {
|
||||
|
||||
/**
|
||||
* @var array
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Assets;
|
||||
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\View\Parsers\SS_Transliterator;
|
||||
use SilverStripe\View\Parsers\Transliterator;
|
||||
|
||||
/**
|
||||
* Filter certain characters from file name, for nicer (more SEO-friendly) URLs
|
||||
@ -95,22 +95,22 @@ class FileNameFilter extends Object {
|
||||
}
|
||||
|
||||
/**
|
||||
* @var SS_Transliterator
|
||||
* @var Transliterator
|
||||
*/
|
||||
protected $transliterator;
|
||||
|
||||
/**
|
||||
* @return SS_Transliterator|NULL
|
||||
* @return Transliterator
|
||||
*/
|
||||
public function getTransliterator() {
|
||||
if($this->transliterator === null && $this->config()->default_use_transliterator) {
|
||||
$this->transliterator = SS_Transliterator::create();
|
||||
$this->transliterator = Transliterator::create();
|
||||
}
|
||||
return $this->transliterator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_Transliterator|FALSE
|
||||
* @param Transliterator $t
|
||||
*/
|
||||
public function setTransliterator($t) {
|
||||
$this->transliterator = $t;
|
||||
|
@ -15,7 +15,7 @@ use SilverStripe\Assets\Storage\AssetStore;
|
||||
use SilverStripe\Assets\Storage\AssetStoreRouter;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Flushable;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
@ -804,17 +804,17 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an {@see SS_HTTPResponse} for the given file from the source filesystem
|
||||
* Generate an {@see HTTPResponse} for the given file from the source filesystem
|
||||
* @param FilesystemInterface $flysystem
|
||||
* @param string $fileID
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
protected function createResponseFor(FilesystemInterface $flysystem, $fileID) {
|
||||
// Build response body
|
||||
// @todo: gzip / buffer response?
|
||||
$body = $flysystem->read($fileID);
|
||||
$mime = $flysystem->getMimetype($fileID);
|
||||
$response = new SS_HTTPResponse($body, 200);
|
||||
$response = new HTTPResponse($body, 200);
|
||||
|
||||
// Add headers
|
||||
$response->addHeader('Content-Type', $mime);
|
||||
@ -828,7 +828,7 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
||||
/**
|
||||
* Generate a response for requests to a denied protected file
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
protected function createDeniedResponse() {
|
||||
$code = (int)Config::inst()->get(get_class($this), 'denied_response_code');
|
||||
@ -838,7 +838,7 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
||||
/**
|
||||
* Generate a response for missing file requests
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
protected function createMissingResponse() {
|
||||
$code = (int)Config::inst()->get(get_class($this), 'missing_response_code');
|
||||
@ -849,10 +849,10 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
||||
* Create a response with the given error code
|
||||
*
|
||||
* @param int $code
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
protected function createErrorResponse($code) {
|
||||
$response = new SS_HTTPResponse('', $code);
|
||||
$response = new HTTPResponse('', $code);
|
||||
|
||||
// Show message in dev
|
||||
if(!Director::isLive()) {
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Assets;
|
||||
|
||||
use SilverStripe\Assets\Storage\AssetContainer;
|
||||
use SilverStripe\Assets\Storage\AssetStore;
|
||||
use SilverStripe\Core\SS_Cache;
|
||||
use SilverStripe\Core\Cache;
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\Core\Flushable;
|
||||
use InvalidArgumentException;
|
||||
@ -64,7 +64,7 @@ class GDBackend extends Object implements Image_Backend, Flushable {
|
||||
|
||||
public function __construct(AssetContainer $assetContainer = null) {
|
||||
parent::__construct();
|
||||
$this->cache = SS_Cache::factory('GDBackend_Manipulations');
|
||||
$this->cache = Cache::factory('GDBackend_Manipulations');
|
||||
|
||||
if($assetContainer) {
|
||||
$this->loadFromContainer($assetContainer);
|
||||
@ -661,7 +661,7 @@ class GDBackend extends Object implements Image_Backend, Flushable {
|
||||
|
||||
public static function flush() {
|
||||
// Clear factory
|
||||
$cache = SS_Cache::factory('GDBackend_Manipulations');
|
||||
$cache = Cache::factory('GDBackend_Manipulations');
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace SilverStripe\Assets\Storage;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
|
||||
/**
|
||||
* Represents a store usable with ProtectedFileController to serve up non-direct file requests
|
||||
@ -15,8 +15,8 @@ interface AssetStoreRouter {
|
||||
*
|
||||
*
|
||||
* @param string $asset Asset path name, omitting any leading 'assets'
|
||||
* @return SS_HTTPResponse
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @return HTTPResponse
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public function getResponseFor($asset);
|
||||
}
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\Assets\Storage;
|
||||
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
|
||||
/**
|
||||
* Provides routing for session-whitelisted protected files
|
||||
@ -46,10 +46,10 @@ class ProtectedFileController extends Controller {
|
||||
/**
|
||||
* Provide a response for the given file request
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function handleFile(SS_HTTPRequest $request) {
|
||||
public function handleFile(HTTPRequest $request) {
|
||||
$filename = $this->parseFilename($request);
|
||||
|
||||
// Deny requests to private file
|
||||
@ -76,10 +76,10 @@ class ProtectedFileController extends Controller {
|
||||
/**
|
||||
* Get the file component from the request
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return string
|
||||
*/
|
||||
protected function parseFilename(SS_HTTPRequest $request) {
|
||||
protected function parseFilename(HTTPRequest $request) {
|
||||
$filename = '';
|
||||
$next = $request->param('Filename');
|
||||
while($next) {
|
||||
|
@ -65,7 +65,7 @@ class ContentNegotiator extends Object {
|
||||
* Returns true if negotiation is enabled for the given response. By default, negotiation is only
|
||||
* enabled for pages that have the xml header.
|
||||
*
|
||||
* @param SS_HTTPResponse $response
|
||||
* @param HTTPResponse $response
|
||||
* @return bool
|
||||
*/
|
||||
public static function enabled_for($response) {
|
||||
@ -87,9 +87,9 @@ class ContentNegotiator extends Object {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPResponse $response
|
||||
* @param HTTPResponse $response
|
||||
*/
|
||||
public static function process(SS_HTTPResponse $response) {
|
||||
public static function process(HTTPResponse $response) {
|
||||
if(!self::enabled_for($response)) return;
|
||||
|
||||
$mimes = array(
|
||||
@ -137,11 +137,11 @@ class ContentNegotiator extends Object {
|
||||
* Replaces a few common tags and entities with their XHTML representations (<br>, <img>,
|
||||
* <input>, checked, selected).
|
||||
*
|
||||
* @param SS_HTTPResponse $response
|
||||
* @param HTTPResponse $response
|
||||
*
|
||||
* @todo Search for more xhtml replacement
|
||||
*/
|
||||
public function xhtml(SS_HTTPResponse $response) {
|
||||
public function xhtml(HTTPResponse $response) {
|
||||
$content = $response->getBody();
|
||||
$encoding = Config::inst()->get('SilverStripe\\Control\\ContentNegotiator', 'encoding');
|
||||
|
||||
@ -177,9 +177,9 @@ class ContentNegotiator extends Object {
|
||||
* - Replaces all occurrences of "application/xhtml+xml" with "text/html" in the template.
|
||||
* - Removes "xmlns" attributes and any <?xml> Pragmas.
|
||||
*
|
||||
* @param SS_HTTPResponse $response
|
||||
* @param HTTPResponse $response
|
||||
*/
|
||||
public function html(SS_HTTPResponse $response) {
|
||||
public function html(HTTPResponse $response) {
|
||||
$encoding = $this->config()->get('encoding');
|
||||
$contentType = $this->config()->get('content_type');
|
||||
if (empty($contentType)) {
|
||||
|
@ -30,7 +30,7 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
protected $urlParams;
|
||||
|
||||
/**
|
||||
* Contains all GET and POST parameters passed to the current {@link SS_HTTPRequest}.
|
||||
* Contains all GET and POST parameters passed to the current {@link HTTPRequest}.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
@ -70,7 +70,7 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
*
|
||||
* Set in {@link handleRequest()}.
|
||||
*
|
||||
* @var SS_HTTPResponse
|
||||
* @var HTTPResponse
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
@ -155,15 +155,15 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
*
|
||||
* @todo setDataModel and setRequest are redundantly called in parent::handleRequest() - sort this out
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @param DataModel $model
|
||||
*/
|
||||
protected function beforeHandleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||
protected function beforeHandleRequest(HTTPRequest $request, DataModel $model) {
|
||||
//Push the current controller to protect against weird session issues
|
||||
$this->pushCurrent();
|
||||
//Set up the internal dependencies (request, response, datamodel)
|
||||
$this->setRequest($request);
|
||||
$this->setResponse(new SS_HTTPResponse());
|
||||
$this->setResponse(new HTTPResponse());
|
||||
$this->setDataModel($model);
|
||||
//kick off the init functionality
|
||||
$this->doInit();
|
||||
@ -179,7 +179,7 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes this controller, and return an {@link SS_HTTPResponse} object with the result.
|
||||
* Executes this controller, and return an {@link HTTPResponse} object with the result.
|
||||
*
|
||||
* This method defers to {@link RequestHandler->handleRequest()} to determine which action
|
||||
* should be executed
|
||||
@ -194,12 +194,12 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
* make sure that you start the method with $this->beforeHandleRequest()
|
||||
* and end the method with $this->afterHandleRequest()
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @param DataModel $model
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||
public function handleRequest(HTTPRequest $request, DataModel $model) {
|
||||
if (!$request) {
|
||||
user_error("Controller::handleRequest() not passed a request!", E_USER_ERROR);
|
||||
}
|
||||
@ -229,13 +229,13 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
* Prepare the response (we can receive an assortment of response types (strings/objects/HTTPResponses) and
|
||||
* changes the controller response object appropriately
|
||||
*
|
||||
* @param SS_HTTPResponse|Object $response
|
||||
* @param HTTPResponse|Object $response
|
||||
*/
|
||||
protected function prepareResponse($response) {
|
||||
if ($response instanceof SS_HTTPResponse) {
|
||||
if ($response instanceof HTTPResponse) {
|
||||
if (isset($_REQUEST['debug_request'])) {
|
||||
Debug::message(
|
||||
"Request handler returned SS_HTTPResponse object to $this->class controller;"
|
||||
"Request handler returned HTTPResponse object to $this->class controller;"
|
||||
. "returning it without modification."
|
||||
);
|
||||
}
|
||||
@ -267,10 +267,10 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
* Controller's default action handler. It will call the method named in "$Action", if that method
|
||||
* exists. If "$Action" isn't given, it will use "index" as a default.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @param string $action
|
||||
*
|
||||
* @return DBHTMLText|SS_HTTPResponse
|
||||
* @return DBHTMLText|HTTPResponse
|
||||
*/
|
||||
protected function handleAction($request, $action) {
|
||||
foreach($request->latestParams() as $k => $v) {
|
||||
@ -326,26 +326,26 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SS_HTTPResponse object that this controller is building up. Can be used to set the
|
||||
* Returns the HTTPResponse object that this controller is building up. Can be used to set the
|
||||
* status code and headers.
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function getResponse() {
|
||||
if (!$this->response) {
|
||||
$this->setResponse(new SS_HTTPResponse());
|
||||
$this->setResponse(new HTTPResponse());
|
||||
}
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SS_HTTPResponse object that this controller is building up.
|
||||
* Sets the HTTPResponse object that this controller is building up.
|
||||
*
|
||||
* @param SS_HTTPResponse $response
|
||||
* @param HTTPResponse $response
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setResponse(SS_HTTPResponse $response) {
|
||||
public function setResponse(HTTPResponse $response) {
|
||||
$this->response = $response;
|
||||
return $this;
|
||||
}
|
||||
@ -602,7 +602,7 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $code
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function redirect($url, $code = 302) {
|
||||
if($this->getResponse()->getHeader('Location') && $this->getResponse()->getHeader('Location') != $url) {
|
||||
@ -627,7 +627,7 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
*
|
||||
* @uses redirect()
|
||||
*
|
||||
* @return bool|SS_HTTPResponse
|
||||
* @return bool|HTTPResponse
|
||||
*/
|
||||
public function redirectBack() {
|
||||
// Don't cache the redirect back ever
|
||||
|
@ -118,7 +118,7 @@ class Director implements TemplateGlobalProvider {
|
||||
* Process the given URL, creating the appropriate controller and executing it.
|
||||
*
|
||||
* Request processing is handled as follows:
|
||||
* - Director::direct() creates a new SS_HTTPResponse object and passes this to
|
||||
* - Director::direct() creates a new HTTPResponse object and passes this to
|
||||
* Director::handleRequest().
|
||||
* - Director::handleRequest($request) checks each of the Director rules and identifies a controller
|
||||
* to handle this request.
|
||||
@ -134,7 +134,7 @@ class Director implements TemplateGlobalProvider {
|
||||
* @uses Controller::handleRequest() This handles the page logic for a Director::direct() call.
|
||||
* @param string $url
|
||||
* @param DataModel $model
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public static function direct($url, DataModel $model) {
|
||||
// Validate $_FILES array before merging it with $_POST
|
||||
@ -153,7 +153,7 @@ class Director implements TemplateGlobalProvider {
|
||||
}
|
||||
}
|
||||
|
||||
$req = new SS_HTTPRequest(
|
||||
$req = new HTTPRequest(
|
||||
(isset($_SERVER['X-HTTP-Method-Override']))
|
||||
? $_SERVER['X-HTTP-Method-Override']
|
||||
: $_SERVER['REQUEST_METHOD'],
|
||||
@ -180,7 +180,7 @@ class Director implements TemplateGlobalProvider {
|
||||
|
||||
if ($output === false) {
|
||||
// @TODO Need to NOT proceed with the request in an elegant manner
|
||||
throw new SS_HTTPResponse_Exception(_t('Director.INVALID_REQUEST', 'Invalid request'), 400);
|
||||
throw new HTTPResponse_Exception(_t('Director.INVALID_REQUEST', 'Invalid request'), 400);
|
||||
}
|
||||
|
||||
$result = Director::handleRequest($req, $session, $model);
|
||||
@ -200,7 +200,7 @@ class Director implements TemplateGlobalProvider {
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
$response = new SS_HTTPResponse();
|
||||
$response = new HTTPResponse();
|
||||
$response->redirect($url);
|
||||
$res = RequestProcessor::singleton()->postRequest($req, $response, $model);
|
||||
|
||||
@ -210,11 +210,11 @@ class Director implements TemplateGlobalProvider {
|
||||
}
|
||||
// Handle a controller
|
||||
} elseif ($result) {
|
||||
if ($result instanceof SS_HTTPResponse) {
|
||||
if ($result instanceof HTTPResponse) {
|
||||
$response = $result;
|
||||
|
||||
} else {
|
||||
$response = new SS_HTTPResponse();
|
||||
$response = new HTTPResponse();
|
||||
$response->setBody($result);
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ class Director implements TemplateGlobalProvider {
|
||||
$response->output();
|
||||
} else {
|
||||
// @TODO Proper response here.
|
||||
throw new SS_HTTPResponse_Exception("Invalid response");
|
||||
throw new HTTPResponse_Exception("Invalid response");
|
||||
}
|
||||
|
||||
|
||||
@ -234,7 +234,7 @@ class Director implements TemplateGlobalProvider {
|
||||
/**
|
||||
* Test a URL request, returning a response object. This method is the counterpart of
|
||||
* Director::direct() that is used in functional testing. It will execute the URL given, and
|
||||
* return the result as an SS_HTTPResponse object.
|
||||
* return the result as an HTTPResponse object.
|
||||
*
|
||||
* @uses Controller::handleRequest() Handles the page logic for a Director::direct() call.
|
||||
*
|
||||
@ -248,11 +248,11 @@ class Director implements TemplateGlobalProvider {
|
||||
* @param string $body The HTTP body.
|
||||
* @param array $headers HTTP headers with key-value pairs.
|
||||
* @param array|Cookie_Backend $cookies to populate $_COOKIE.
|
||||
* @param SS_HTTPRequest $request The {@see SS_HTTP_Request} object generated as a part of this request.
|
||||
* @param HTTPRequest $request The {@see SS_HTTP_Request} object generated as a part of this request.
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public static function test($url, $postVars = null, $session = array(), $httpMethod = null, $body = null,
|
||||
$headers = array(), $cookies = array(), &$request = null) {
|
||||
@ -342,7 +342,7 @@ class Director implements TemplateGlobalProvider {
|
||||
Injector::inst()->registerService($cookieJar, 'SilverStripe\\Control\\Cookie_Backend');
|
||||
$_SERVER['REQUEST_URI'] = Director::baseURL() . $urlWithQuerystring;
|
||||
|
||||
$request = new SS_HTTPRequest($httpMethod, $url, $getVars, $postVars, $body);
|
||||
$request = new HTTPRequest($httpMethod, $url, $getVars, $postVars, $body);
|
||||
if ($headers) {
|
||||
foreach($headers as $k => $v) {
|
||||
$request->addHeader($k, $v);
|
||||
@ -355,27 +355,27 @@ class Director implements TemplateGlobalProvider {
|
||||
$output = Injector::inst()->get('SilverStripe\\Control\\RequestProcessor')->preRequest($request, $session, $model);
|
||||
if ($output === false) {
|
||||
$onCleanup();
|
||||
throw new SS_HTTPResponse_Exception(_t('Director.INVALID_REQUEST', 'Invalid request'), 400);
|
||||
throw new HTTPResponse_Exception(_t('Director.INVALID_REQUEST', 'Invalid request'), 400);
|
||||
}
|
||||
|
||||
// TODO: Pass in the DataModel
|
||||
$result = Director::handleRequest($request, $session, $model);
|
||||
|
||||
// Ensure that the result is an SS_HTTPResponse object
|
||||
// Ensure that the result is an HTTPResponse object
|
||||
if (is_string($result)) {
|
||||
if (substr($result, 0, 9) == 'redirect:') {
|
||||
$response = new SS_HTTPResponse();
|
||||
$response = new HTTPResponse();
|
||||
$response->redirect(substr($result, 9));
|
||||
$result = $response;
|
||||
} else {
|
||||
$result = new SS_HTTPResponse($result);
|
||||
$result = new HTTPResponse($result);
|
||||
}
|
||||
}
|
||||
|
||||
$output = Injector::inst()->get('SilverStripe\\Control\\RequestProcessor')->postRequest($request, $result, $model);
|
||||
if ($output === false) {
|
||||
$onCleanup();
|
||||
throw new SS_HTTPResponse_Exception("Invalid response");
|
||||
throw new HTTPResponse_Exception("Invalid response");
|
||||
}
|
||||
|
||||
// Return valid response
|
||||
@ -384,15 +384,15 @@ class Director implements TemplateGlobalProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an HTTP request, defined with a SS_HTTPRequest object.
|
||||
* Handle an HTTP request, defined with a HTTPRequest object.
|
||||
*
|
||||
* @skipUpgrade
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @param Session $session
|
||||
* @param DataModel $model
|
||||
* @return SS_HTTPResponse|string
|
||||
* @return HTTPResponse|string
|
||||
*/
|
||||
protected static function handleRequest(SS_HTTPRequest $request, Session $session, DataModel $model) {
|
||||
protected static function handleRequest(HTTPRequest $request, Session $session, DataModel $model) {
|
||||
$rules = Director::config()->get('rules');
|
||||
|
||||
if (isset($_REQUEST['debug'])) {
|
||||
@ -431,10 +431,10 @@ class Director implements TemplateGlobalProvider {
|
||||
|
||||
try {
|
||||
$result = $controllerObj->handleRequest($request, $model);
|
||||
} catch(SS_HTTPResponse_Exception $responseException) {
|
||||
} catch(HTTPResponse_Exception $responseException) {
|
||||
$result = $responseException->getResponse();
|
||||
}
|
||||
if (!is_object($result) || $result instanceof SS_HTTPResponse) {
|
||||
if (!is_object($result) || $result instanceof HTTPResponse) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ class Director implements TemplateGlobalProvider {
|
||||
}
|
||||
|
||||
// No URL rules matched, so return a 404 error.
|
||||
return new SS_HTTPResponse('No URL rule was matched', 404);
|
||||
return new HTTPResponse('No URL rule was matched', 404);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -912,7 +912,7 @@ class Director implements TemplateGlobalProvider {
|
||||
* @param string $destURL
|
||||
*/
|
||||
protected static function force_redirect($destURL) {
|
||||
$response = new SS_HTTPResponse();
|
||||
$response = new HTTPResponse();
|
||||
$response->redirect($destURL, 301);
|
||||
|
||||
HTTP::add_cache_headers($response);
|
||||
|
@ -13,13 +13,13 @@ class FlushRequestFilter implements RequestFilter {
|
||||
/**
|
||||
* @inheritdoc
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @param Session $session
|
||||
* @param DataModel $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model) {
|
||||
public function preRequest(HTTPRequest $request, Session $session, DataModel $model) {
|
||||
if(array_key_exists('flush', $request->getVars())) {
|
||||
foreach(ClassInfo::implementorsOf('SilverStripe\\Core\\Flushable') as $class) {
|
||||
$class::flush();
|
||||
@ -32,13 +32,13 @@ class FlushRequestFilter implements RequestFilter {
|
||||
/**
|
||||
* @inheritdoc
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param SS_HTTPResponse $response
|
||||
* @param HTTPRequest $request
|
||||
* @param HTTPResponse $response
|
||||
* @param DataModel $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model) {
|
||||
public function postRequest(HTTPRequest $request, HTTPResponse $response, DataModel $model) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -348,14 +348,14 @@ class HTTP {
|
||||
* Omitting the $body argument or passing a string is deprecated; in these cases, the headers are
|
||||
* output directly.
|
||||
*
|
||||
* @param SS_HTTPResponse $body
|
||||
* @param HTTPResponse $body
|
||||
*/
|
||||
public static function add_cache_headers($body = null) {
|
||||
$cacheAge = self::$cache_age;
|
||||
|
||||
// Validate argument
|
||||
if($body && !($body instanceof SS_HTTPResponse)) {
|
||||
user_error("HTTP::add_cache_headers() must be passed an SS_HTTPResponse object", E_USER_WARNING);
|
||||
if($body && !($body instanceof HTTPResponse)) {
|
||||
user_error("HTTP::add_cache_headers() must be passed an HTTPResponse object", E_USER_WARNING);
|
||||
$body = null;
|
||||
}
|
||||
|
||||
@ -365,7 +365,7 @@ class HTTP {
|
||||
$cacheAge = 0;
|
||||
}
|
||||
|
||||
// The headers have been sent and we don't have an SS_HTTPResponse object to attach things to; no point in
|
||||
// The headers have been sent and we don't have an HTTPResponse object to attach things to; no point in
|
||||
// us trying.
|
||||
if(headers_sent() && !$body) {
|
||||
return;
|
||||
@ -503,7 +503,7 @@ class HTTP {
|
||||
$responseHeaders['ETag'] = sprintf('"%s"', $responseHeaders['ETag']);
|
||||
}
|
||||
|
||||
// Now that we've generated them, either output them or attach them to the SS_HTTPResponse as appropriate
|
||||
// Now that we've generated them, either output them or attach them to the HTTPResponse as appropriate
|
||||
foreach($responseHeaders as $k => $v) {
|
||||
if($body) {
|
||||
// Set the header now if it's not already set.
|
||||
|
@ -13,14 +13,14 @@ use ArrayAccess;
|
||||
* Caution: objects of this class are immutable, e.g. echo $request['a']; works as expected,
|
||||
* but $request['a'] = '1'; has no effect.
|
||||
*
|
||||
* The intention is that a single SS_HTTPRequest object can be passed from one object to another, each object calling
|
||||
* The intention is that a single HTTPRequest object can be passed from one object to another, each object calling
|
||||
* match() to get the information that they need out of the URL. This is generally handled by
|
||||
* {@link RequestHandler::handleRequest()}.
|
||||
*
|
||||
* @todo Accept X_HTTP_METHOD_OVERRIDE http header and $_REQUEST['_method'] to override request types (useful for
|
||||
* webclients not supporting PUT and DELETE)
|
||||
*/
|
||||
class SS_HTTPRequest implements ArrayAccess {
|
||||
class HTTPRequest implements ArrayAccess {
|
||||
|
||||
/**
|
||||
* @var string
|
||||
@ -125,7 +125,7 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
protected $unshiftedButParsedParts = 0;
|
||||
|
||||
/**
|
||||
* Construct a SS_HTTPRequest from a URL relative to the site root.
|
||||
* Construct a HTTPRequest from a URL relative to the site root.
|
||||
*
|
||||
* @param string $httpMethod
|
||||
* @param string $url
|
||||
@ -149,7 +149,7 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
* without us loosing all the other info attached (like headers)
|
||||
*
|
||||
* @param string $url The new URL
|
||||
* @return SS_HTTPRequest The updated request
|
||||
* @return HTTPRequest The updated request
|
||||
*/
|
||||
public function setUrl($url) {
|
||||
$this->url = $url;
|
||||
@ -208,7 +208,7 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
|
||||
/**
|
||||
* @param string $body
|
||||
* @return SS_HTTPRequest $this
|
||||
* @return HTTPRequest $this
|
||||
*/
|
||||
public function setBody($body) {
|
||||
$this->body = $body;
|
||||
@ -296,7 +296,7 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the {@link SS_HTTPRequest->getExtension()} on this request matches one of the more common media types
|
||||
* Checks if the {@link HTTPRequest->getExtension()} on this request matches one of the more common media types
|
||||
* embedded into a webpage - e.g. css, png.
|
||||
*
|
||||
* This is useful for things like determining wether to display a fully rendered error page or not. Note that the
|
||||
@ -340,7 +340,7 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
* e.g. "Content-Type".
|
||||
*
|
||||
* @param string $header
|
||||
* @return SS_HTTPRequest $this
|
||||
* @return HTTPRequest $this
|
||||
*/
|
||||
public function removeHeader($header) {
|
||||
if(isset($this->headers[$header])) unset($this->headers[$header]);
|
||||
@ -422,7 +422,7 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
public function offsetUnset($offset) {}
|
||||
|
||||
/**
|
||||
* Construct an SS_HTTPResponse that will deliver a file to the client.
|
||||
* Construct an HTTPResponse that will deliver a file to the client.
|
||||
* Caution: Since it requires $fileData to be passed as binary data (no stream support),
|
||||
* it's only advisable to send small files through this method.
|
||||
*
|
||||
@ -430,13 +430,13 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
* @param $fileData
|
||||
* @param $fileName
|
||||
* @param null $mimeType
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public static function send_file($fileData, $fileName, $mimeType = null) {
|
||||
if(!$mimeType) {
|
||||
$mimeType = HTTP::get_mime_type($fileName);
|
||||
}
|
||||
$response = new SS_HTTPResponse($fileData);
|
||||
$response = new HTTPResponse($fileData);
|
||||
$response->addHeader("Content-Type", "$mimeType; name=\"" . addslashes($fileName) . "\"");
|
||||
// Note a IE-only fix that inspects this header in HTTP::add_cache_headers().
|
||||
$response->addHeader("Content-Disposition", "attachment; filename=" . addslashes($fileName));
|
||||
@ -610,7 +610,7 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
* @return SS_HTTPRequest $this
|
||||
* @return HTTPRequest $this
|
||||
*/
|
||||
public function setRouteParams($params) {
|
||||
$this->routeParams = $params;
|
@ -10,7 +10,7 @@ use SilverStripe\View\Requirements;
|
||||
/**
|
||||
* Represents a response returned by a controller.
|
||||
*/
|
||||
class SS_HTTPResponse {
|
||||
class HTTPResponse {
|
||||
|
||||
/**
|
||||
* @var array
|
@ -5,32 +5,32 @@ namespace SilverStripe\Control;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* A {@link SS_HTTPResponse} encapsulated in an exception, which can interrupt the processing flow and be caught by the
|
||||
* A {@link HTTPResponse} encapsulated in an exception, which can interrupt the processing flow and be caught by the
|
||||
* {@link RequestHandler} and returned to the user.
|
||||
*
|
||||
* Example Usage:
|
||||
* <code>
|
||||
* throw new SS_HTTPResponse_Exception('This request was invalid.', 400);
|
||||
* throw new SS_HTTPResponse_Exception(new SS_HTTPResponse('There was an internal server error.', 500));
|
||||
* throw new HTTPResponse_Exception('This request was invalid.', 400);
|
||||
* throw new HTTPResponse_Exception(new HTTPResponse('There was an internal server error.', 500));
|
||||
* </code>
|
||||
*/
|
||||
class SS_HTTPResponse_Exception extends Exception
|
||||
class HTTPResponse_Exception extends Exception
|
||||
{
|
||||
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* @param SS_HTTPResponse|string $body Either the plaintext content of the error
|
||||
* message, or an SS_HTTPResponse object representing it. In either case, the
|
||||
* @param HTTPResponse|string $body Either the plaintext content of the error
|
||||
* message, or an HTTPResponse object representing it. In either case, the
|
||||
* $statusCode and $statusDescription will be the HTTP status of the resulting
|
||||
* response.
|
||||
* @param int $statusCode
|
||||
* @param string $statusDescription
|
||||
* @see SS_HTTPResponse::__construct();
|
||||
* @see HTTPResponse::__construct();
|
||||
*/
|
||||
public function __construct($body = null, $statusCode = null, $statusDescription = null)
|
||||
{
|
||||
if ($body instanceof SS_HTTPResponse) {
|
||||
if ($body instanceof HTTPResponse) {
|
||||
// statusCode and statusDescription should override whatever is passed in the body
|
||||
if ($statusCode) {
|
||||
$body->setStatusCode($statusCode);
|
||||
@ -41,7 +41,7 @@ class SS_HTTPResponse_Exception extends Exception
|
||||
|
||||
$this->setResponse($body);
|
||||
} else {
|
||||
$response = new SS_HTTPResponse($body, $statusCode, $statusDescription);
|
||||
$response = new HTTPResponse($body, $statusCode, $statusDescription);
|
||||
|
||||
// Error responses should always be considered plaintext, for security reasons
|
||||
$response->addHeader('Content-Type', 'text/plain');
|
||||
@ -53,7 +53,7 @@ class SS_HTTPResponse_Exception extends Exception
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
@ -61,9 +61,9 @@ class SS_HTTPResponse_Exception extends Exception
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPResponse $response
|
||||
* @param HTTPResponse $response
|
||||
*/
|
||||
public function setResponse(SS_HTTPResponse $response)
|
||||
public function setResponse(HTTPResponse $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
@ -7,7 +7,7 @@ namespace SilverStripe\Control;
|
||||
* Set on controllers on construction time, typically overwritten
|
||||
* by {@link Controller->handleRequest()} and {@link Controller->handleAction()} later on.
|
||||
*/
|
||||
class NullHTTPRequest extends SS_HTTPRequest {
|
||||
class NullHTTPRequest extends HTTPRequest {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct(null, null);
|
||||
|
@ -38,7 +38,7 @@ class PjaxResponseNegotiator {
|
||||
|
||||
/**
|
||||
* @param array $callbacks
|
||||
* @param SS_HTTPResponse $response An existing response to reuse (optional)
|
||||
* @param HTTPResponse $response An existing response to reuse (optional)
|
||||
*/
|
||||
public function __construct($callbacks = array(), $response = null) {
|
||||
$this->callbacks = $callbacks;
|
||||
@ -47,7 +47,7 @@ class PjaxResponseNegotiator {
|
||||
|
||||
public function getResponse() {
|
||||
if(!$this->response) {
|
||||
$this->response = new SS_HTTPResponse();
|
||||
$this->response = new HTTPResponse();
|
||||
}
|
||||
return $this->response;
|
||||
}
|
||||
@ -60,14 +60,14 @@ class PjaxResponseNegotiator {
|
||||
* Out of the box, the handler "CurrentForm" value, which will return the rendered form.
|
||||
* Non-Ajax calls will redirect back.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @param array $extraCallbacks List of anonymous functions or callables returning either a string
|
||||
* or SS_HTTPResponse, keyed by their fragment identifier. The 'default' key can
|
||||
* or HTTPResponse, keyed by their fragment identifier. The 'default' key can
|
||||
* be used as a fallback for non-ajax responses.
|
||||
* @return SS_HTTPResponse
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @return HTTPResponse
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public function respond(SS_HTTPRequest $request, $extraCallbacks = array()) {
|
||||
public function respond(HTTPRequest $request, $extraCallbacks = array()) {
|
||||
// Prepare the default options and combine with the others
|
||||
$callbacks = array_merge($this->callbacks, $extraCallbacks);
|
||||
$response = $this->getResponse();
|
||||
@ -80,9 +80,9 @@ class PjaxResponseNegotiator {
|
||||
$fragments = explode(',', $fragmentStr);
|
||||
} else {
|
||||
if($request->isAjax()) {
|
||||
throw new SS_HTTPResponse_Exception("Ajax requests to this URL require an X-Pjax header.", 400);
|
||||
throw new HTTPResponse_Exception("Ajax requests to this URL require an X-Pjax header.", 400);
|
||||
} elseif (empty($callbacks['default'])) {
|
||||
throw new SS_HTTPResponse_Exception("Missing default response handler for this URL", 400);
|
||||
throw new HTTPResponse_Exception("Missing default response handler for this URL", 400);
|
||||
}
|
||||
$response->setBody(call_user_func($callbacks['default']));
|
||||
return $response;
|
||||
@ -94,7 +94,7 @@ class PjaxResponseNegotiator {
|
||||
$res = call_user_func($callbacks[$fragment]);
|
||||
$responseParts[$fragment] = $res ? (string) $res : $res;
|
||||
} else {
|
||||
throw new SS_HTTPResponse_Exception("X-Pjax = '$fragment' not supported for this URL.", 400);
|
||||
throw new HTTPResponse_Exception("X-Pjax = '$fragment' not supported for this URL.", 400);
|
||||
}
|
||||
}
|
||||
$response->setBody(Convert::raw2json($responseParts));
|
||||
|
@ -200,7 +200,7 @@ class RSSFeed extends ViewableData {
|
||||
/**
|
||||
* Output the feed to the browser.
|
||||
*
|
||||
* TODO: Pass $response object to ->outputToBrowser() to loosen dependence on global state for easier testing/prototyping so dev can inject custom SS_HTTPResponse instance.
|
||||
* TODO: Pass $response object to ->outputToBrowser() to loosen dependence on global state for easier testing/prototyping so dev can inject custom HTTPResponse instance.
|
||||
*
|
||||
* @return DBHTMLText
|
||||
*/
|
||||
|
@ -17,20 +17,20 @@ interface RequestFilter {
|
||||
/**
|
||||
* Filter executed before a request processes
|
||||
*
|
||||
* @param SS_HTTPRequest $request Request container object
|
||||
* @param HTTPRequest $request Request container object
|
||||
* @param Session $session Request session
|
||||
* @param DataModel $model Current DataModel
|
||||
* @return boolean Whether to continue processing other filters. Null or true will continue processing (optional)
|
||||
*/
|
||||
public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model);
|
||||
public function preRequest(HTTPRequest $request, Session $session, DataModel $model);
|
||||
|
||||
/**
|
||||
* Filter executed AFTER a request
|
||||
*
|
||||
* @param SS_HTTPRequest $request Request container object
|
||||
* @param SS_HTTPResponse $response Response output object
|
||||
* @param HTTPRequest $request Request container object
|
||||
* @param HTTPResponse $response Response output object
|
||||
* @param DataModel $model Current DataModel
|
||||
* @return boolean Whether to continue processing other filters. Null or true will continue processing (optional)
|
||||
*/
|
||||
public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model);
|
||||
public function postRequest(HTTPRequest $request, HTTPResponse $response, DataModel $model);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use BadMethodCallException;
|
||||
* Any RequestHandler object can be made responsible for handling its own segment of the URL namespace.
|
||||
* The {@link Director} begins the URL parsing process; it will parse the beginning of the URL to identify which
|
||||
* controller is being used. It will then call {@link handleRequest()} on that Controller, passing it the parameters
|
||||
* that it parsed from the URL, and the {@link SS_HTTPRequest} that contains the remainder of the URL to be parsed.
|
||||
* that it parsed from the URL, and the {@link HTTPRequest} that contains the remainder of the URL to be parsed.
|
||||
*
|
||||
* You can use ?debug_request=1 to view information about the different components and rule matches for a specific URL.
|
||||
*
|
||||
@ -48,7 +48,7 @@ use BadMethodCallException;
|
||||
class RequestHandler extends ViewableData {
|
||||
|
||||
/**
|
||||
* @var SS_HTTPRequest $request The request object that the controller was called with.
|
||||
* @var HTTPRequest $request The request object that the controller was called with.
|
||||
* Set in {@link handleRequest()}. Useful to generate the {}
|
||||
*/
|
||||
protected $request = null;
|
||||
@ -71,7 +71,7 @@ class RequestHandler extends ViewableData {
|
||||
* The default URL handling rules. This specifies that the next component of the URL corresponds to a method to
|
||||
* be called on this RequestHandlingData object.
|
||||
*
|
||||
* The keys of this array are parse rules. See {@link SS_HTTPRequest::match()} for a description of the rules
|
||||
* The keys of this array are parse rules. See {@link HTTPRequest::match()} for a description of the rules
|
||||
* available.
|
||||
*
|
||||
* The values of the array are the method to be called if the rule matches. If this value starts with a '$', then
|
||||
@ -155,11 +155,11 @@ class RequestHandler extends ViewableData {
|
||||
* action will return an array of data with which to
|
||||
* customise the controller.
|
||||
*
|
||||
* @param SS_HTTPRequest $request The object that is reponsible for distributing URL parsing
|
||||
* @param HTTPRequest $request The object that is reponsible for distributing URL parsing
|
||||
* @param DataModel $model
|
||||
* @return SS_HTTPResponse|RequestHandler|string|array
|
||||
* @return HTTPResponse|RequestHandler|string|array
|
||||
*/
|
||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||
public function handleRequest(HTTPRequest $request, DataModel $model) {
|
||||
// $handlerClass is used to step up the class hierarchy to implement url_handlers inheritance
|
||||
if($this->brokenOnConstruct) {
|
||||
$handlerClass = get_class($this);
|
||||
@ -214,14 +214,14 @@ class RequestHandler extends ViewableData {
|
||||
}
|
||||
$result = $this->handleAction($request, $action);
|
||||
}
|
||||
catch (SS_HTTPResponse_Exception $e) {
|
||||
catch (HTTPResponse_Exception $e) {
|
||||
return $e->getResponse();
|
||||
}
|
||||
catch(PermissionFailureException $e) {
|
||||
$result = Security::permissionFailure(null, $e->getMessage());
|
||||
}
|
||||
|
||||
if($result instanceof SS_HTTPResponse && $result->isError()) {
|
||||
if($result instanceof HTTPResponse && $result->isError()) {
|
||||
if(isset($_REQUEST['debug_request'])) Debug::message("Rule resulted in HTTP error; breaking");
|
||||
return $result;
|
||||
}
|
||||
@ -252,7 +252,7 @@ class RequestHandler extends ViewableData {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return array
|
||||
*/
|
||||
protected function findAction($request) {
|
||||
@ -287,17 +287,17 @@ class RequestHandler extends ViewableData {
|
||||
/**
|
||||
* Given a request, and an action name, call that action name on this RequestHandler
|
||||
*
|
||||
* Must not raise SS_HTTPResponse_Exceptions - instead it should return
|
||||
* Must not raise HTTPResponse_Exceptions - instead it should return
|
||||
*
|
||||
* @param $request
|
||||
* @param $action
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
protected function handleAction($request, $action) {
|
||||
$classMessage = Director::isLive() ? 'on this handler' : 'on class '.get_class($this);
|
||||
|
||||
if(!$this->hasMethod($action)) {
|
||||
return new SS_HTTPResponse("Action '$action' isn't available $classMessage.", 404);
|
||||
return new HTTPResponse("Action '$action' isn't available $classMessage.", 404);
|
||||
}
|
||||
|
||||
$res = $this->extend('beforeCallActionHandler', $request, $action);
|
||||
@ -480,13 +480,13 @@ class RequestHandler extends ViewableData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws a HTTP error response encased in a {@link SS_HTTPResponse_Exception}, which is later caught in
|
||||
* Throws a HTTP error response encased in a {@link HTTPResponse_Exception}, which is later caught in
|
||||
* {@link RequestHandler::handleAction()} and returned to the user.
|
||||
*
|
||||
* @param int $errorCode
|
||||
* @param string $errorMessage Plaintext error message
|
||||
* @uses SS_HTTPResponse_Exception
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @uses HTTPResponse_Exception
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public function httpError($errorCode, $errorMessage = null) {
|
||||
|
||||
@ -499,16 +499,16 @@ class RequestHandler extends ViewableData {
|
||||
$this->extend('onBeforeHTTPError', $errorCode, $request);
|
||||
|
||||
// Throw a new exception
|
||||
throw new SS_HTTPResponse_Exception($errorMessage, $errorCode);
|
||||
throw new HTTPResponse_Exception($errorMessage, $errorCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SS_HTTPRequest object that this controller is using.
|
||||
* Returns the HTTPRequest object that this controller is using.
|
||||
* Returns a placeholder {@link NullHTTPRequest} object unless
|
||||
* {@link handleAction()} or {@link handleRequest()} have been called,
|
||||
* which adds a reference to an actual {@link SS_HTTPRequest} object.
|
||||
* which adds a reference to an actual {@link HTTPRequest} object.
|
||||
*
|
||||
* @return SS_HTTPRequest|NullHTTPRequest
|
||||
* @return HTTPRequest|NullHTTPRequest
|
||||
*/
|
||||
public function getRequest() {
|
||||
return $this->request;
|
||||
@ -518,7 +518,7 @@ class RequestHandler extends ViewableData {
|
||||
* Typically the request is set through {@link handleAction()}
|
||||
* or {@link handleRequest()}, but in some based we want to set it manually.
|
||||
*
|
||||
* @param SS_HTTPRequest
|
||||
* @param HTTPRequest $request
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequest($request) {
|
||||
|
@ -31,7 +31,7 @@ class RequestProcessor implements RequestFilter {
|
||||
$this->filters = $filters;
|
||||
}
|
||||
|
||||
public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model) {
|
||||
public function preRequest(HTTPRequest $request, Session $session, DataModel $model) {
|
||||
foreach ($this->filters as $filter) {
|
||||
$res = $filter->preRequest($request, $session, $model);
|
||||
if ($res === false) {
|
||||
@ -41,7 +41,7 @@ class RequestProcessor implements RequestFilter {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model) {
|
||||
public function postRequest(HTTPRequest $request, HTTPResponse $response, DataModel $model) {
|
||||
foreach ($this->filters as $filter) {
|
||||
$res = $filter->postRequest($request, $response, $model);
|
||||
if ($res === false) {
|
||||
|
@ -13,7 +13,7 @@ use SilverStripe\Security\Security;
|
||||
*/
|
||||
class VersionedRequestFilter implements RequestFilter {
|
||||
|
||||
public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model) {
|
||||
public function preRequest(HTTPRequest $request, Session $session, DataModel $model) {
|
||||
// Bootstrap session so that Session::get() accesses the right instance
|
||||
$dummyController = new Controller();
|
||||
$dummyController->setSession($session);
|
||||
@ -37,7 +37,7 @@ class VersionedRequestFilter implements RequestFilter {
|
||||
$dummyController->popCurrent();
|
||||
// Prevent output in testing
|
||||
if(class_exists('SilverStripe\\Dev\\SapphireTest', false) && SapphireTest::is_running_test()) {
|
||||
throw new SS_HTTPResponse_Exception($response);
|
||||
throw new HTTPResponse_Exception($response);
|
||||
}
|
||||
$response->output();
|
||||
die;
|
||||
@ -48,7 +48,7 @@ class VersionedRequestFilter implements RequestFilter {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model) {
|
||||
public function postRequest(HTTPRequest $request, HTTPResponse $response, DataModel $model) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,12 @@ use Zend_Cache;
|
||||
use Zend_Cache_Core;
|
||||
|
||||
/**
|
||||
* The `[api:SS_Cache]` class provides a bunch of static functions wrapping the Zend_Cache system
|
||||
* The `[api:Cache]` class provides a bunch of static functions wrapping the Zend_Cache system
|
||||
* in something a little more easy to use with the SilverStripe config system.
|
||||
*
|
||||
* @see https://docs.silverstripe.org/en/3.4/developer_guides/performance/caching/
|
||||
*/
|
||||
class SS_Cache {
|
||||
class Cache {
|
||||
|
||||
/**
|
||||
* @var array $backends
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Core;
|
||||
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\ORM\DB;
|
||||
@ -25,7 +25,7 @@ class ClassInfo {
|
||||
* @return array
|
||||
*/
|
||||
public static function allClasses() {
|
||||
return SS_ClassLoader::instance()->getManifest()->getClasses();
|
||||
return ClassLoader::instance()->getManifest()->getClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,7 +35,7 @@ class ClassInfo {
|
||||
* @return bool
|
||||
*/
|
||||
public static function exists($class) {
|
||||
return class_exists($class, false) || interface_exists($class, false) || SS_ClassLoader::instance()->getItemPath($class);
|
||||
return class_exists($class, false) || interface_exists($class, false) || ClassLoader::instance()->getItemPath($class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,7 +153,7 @@ class ClassInfo {
|
||||
|
||||
//normalise class case
|
||||
$className = self::class_name($nameOrObject);
|
||||
$descendants = SS_ClassLoader::instance()->getManifest()->getDescendantsOf($className);
|
||||
$descendants = ClassLoader::instance()->getManifest()->getDescendantsOf($className);
|
||||
$result = array($className => $className);
|
||||
|
||||
if ($descendants) {
|
||||
@ -217,7 +217,7 @@ class ClassInfo {
|
||||
* classes and not built-in PHP classes.
|
||||
*/
|
||||
public static function implementorsOf($interfaceName) {
|
||||
return SS_ClassLoader::instance()->getManifest()->getImplementorsOf($interfaceName);
|
||||
return ClassLoader::instance()->getManifest()->getImplementorsOf($interfaceName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -244,7 +244,7 @@ class ClassInfo {
|
||||
public static function classes_for_file($filePath) {
|
||||
$absFilePath = Director::getAbsFile($filePath);
|
||||
$matchedClasses = array();
|
||||
$manifest = SS_ClassLoader::instance()->getManifest()->getClasses();
|
||||
$manifest = ClassLoader::instance()->getManifest()->getClasses();
|
||||
|
||||
foreach($manifest as $class => $compareFilePath) {
|
||||
if($absFilePath == $compareFilePath) $matchedClasses[] = $class;
|
||||
@ -265,7 +265,7 @@ class ClassInfo {
|
||||
public static function classes_for_folder($folderPath) {
|
||||
$absFolderPath = Director::getAbsFile($folderPath);
|
||||
$matchedClasses = array();
|
||||
$manifest = SS_ClassLoader::instance()->getManifest()->getClasses();
|
||||
$manifest = ClassLoader::instance()->getManifest()->getClasses();
|
||||
|
||||
foreach($manifest as $class => $compareFilePath) {
|
||||
if(stripos($compareFilePath, $absFolderPath) === 0) $matchedClasses[] = $class;
|
||||
|
@ -3,8 +3,8 @@
|
||||
namespace SilverStripe\Core\Config;
|
||||
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\Core\Manifest\SS_ConfigStaticManifest;
|
||||
use SilverStripe\Core\Manifest\SS_ConfigManifest;
|
||||
use SilverStripe\Core\Manifest\ConfigStaticManifest;
|
||||
use SilverStripe\Core\Manifest\ConfigManifest;
|
||||
use UnexpectedValueException;
|
||||
use stdClass;
|
||||
|
||||
@ -304,9 +304,9 @@ class Config {
|
||||
protected $staticManifests = array();
|
||||
|
||||
/**
|
||||
* @param SS_ConfigStaticManifest $manifest
|
||||
* @param ConfigStaticManifest $manifest
|
||||
*/
|
||||
public function pushConfigStaticManifest(SS_ConfigStaticManifest $manifest) {
|
||||
public function pushConfigStaticManifest(ConfigStaticManifest $manifest) {
|
||||
array_unshift($this->staticManifests, $manifest);
|
||||
|
||||
$this->cache->clean();
|
||||
@ -320,9 +320,9 @@ class Config {
|
||||
*
|
||||
* WARNING: Config manifests to not merge entries, and do not solve before/after rules inter-manifest -
|
||||
* instead, the last manifest to be added always wins
|
||||
* @param SS_ConfigManifest $manifest
|
||||
* @param ConfigManifest $manifest
|
||||
*/
|
||||
public function pushConfigYamlManifest(SS_ConfigManifest $manifest) {
|
||||
public function pushConfigYamlManifest(ConfigManifest $manifest) {
|
||||
array_unshift($this->manifests, $manifest);
|
||||
|
||||
// Now that we've got another yaml config manifest we need to clean the cache
|
||||
|
@ -9,7 +9,7 @@ use IteratorAggregate;
|
||||
* A Directed Acyclic Graph - used for doing topological sorts on dependencies, such as the before/after conditions
|
||||
* in config yaml fragments
|
||||
*/
|
||||
class SS_DAG implements IteratorAggregate
|
||||
class DAG implements IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* The nodes/vertices in the graph. Should be a numeric sequence of items (no string keys, no gaps).
|
||||
@ -101,15 +101,15 @@ class SS_DAG implements IteratorAggregate
|
||||
}
|
||||
|
||||
if ($dag) {
|
||||
$remainder = new SS_DAG($data);
|
||||
$remainder = new DAG($data);
|
||||
$remainder->dag = $dag;
|
||||
throw new SS_DAG_CyclicException("DAG has cyclic requirements", $remainder);
|
||||
throw new DAG_CyclicException("DAG has cyclic requirements", $remainder);
|
||||
}
|
||||
return $sorted;
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return new SS_DAG_Iterator($this->data, $this->dag);
|
||||
return new DAG_Iterator($this->data, $this->dag);
|
||||
}
|
||||
}
|
@ -5,17 +5,17 @@ namespace SilverStripe\Core\Config;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Exception thrown when the {@link SilverStripe\Core\Config\SS_DAG} class is unable to resolve sorting the DAG due
|
||||
* Exception thrown when the {@link SilverStripe\Core\Config\DAG} class is unable to resolve sorting the DAG due
|
||||
* to cyclic dependencies.
|
||||
*/
|
||||
class SS_DAG_CyclicException extends Exception
|
||||
class DAG_CyclicException extends Exception
|
||||
{
|
||||
|
||||
public $dag;
|
||||
|
||||
/**
|
||||
* @param string $message The Exception message
|
||||
* @param SS_DAG $dag The remainder of the Directed Acyclic Graph (DAG) after the last successful sort
|
||||
* @param DAG $dag The remainder of the Directed Acyclic Graph (DAG) after the last successful sort
|
||||
*/
|
||||
public function __construct($message, $dag)
|
||||
{
|
@ -4,7 +4,7 @@ namespace SilverStripe\Core\Config;
|
||||
|
||||
use Iterator;
|
||||
|
||||
class SS_DAG_Iterator implements Iterator
|
||||
class DAG_Iterator implements Iterator
|
||||
{
|
||||
|
||||
protected $data;
|
@ -2,10 +2,10 @@
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\Manifest\SS_ClassManifest;
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\SS_ConfigStaticManifest;
|
||||
use SilverStripe\Core\Manifest\SS_ConfigManifest;
|
||||
use SilverStripe\Core\Manifest\ClassManifest;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ConfigStaticManifest;
|
||||
use SilverStripe\Core\Manifest\ConfigManifest;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\i18n\i18n;
|
||||
|
||||
@ -55,16 +55,16 @@ gc_enable();
|
||||
|
||||
// Include the files needed the initial manifest building, as well as any files
|
||||
// that are needed for the boostrap process on every request.
|
||||
require_once 'Core/SS_Cache.php';
|
||||
require_once 'Core/Cache.php';
|
||||
require_once 'Core/CustomMethods.php';
|
||||
require_once 'Core/Extensible.php';
|
||||
require_once 'Core/Injector/Injectable.php';
|
||||
require_once 'Core/Config/Configurable.php';
|
||||
require_once 'Core/Object.php';
|
||||
require_once 'Core/ClassInfo.php';
|
||||
require_once 'Core/Config/SS_DAG.php';
|
||||
require_once 'Core/Config/SS_DAG_CyclicException.php';
|
||||
require_once 'Core/Config/SS_DAG_Iterator.php';
|
||||
require_once 'Core/Config/DAG.php';
|
||||
require_once 'Core/Config/DAG_CyclicException.php';
|
||||
require_once 'Core/Config/DAG_Iterator.php';
|
||||
require_once 'Core/Config/Config.php';
|
||||
require_once 'View/TemplateGlobalProvider.php';
|
||||
require_once 'Control/Director.php';
|
||||
@ -98,19 +98,19 @@ $requestURL = isset($_REQUEST['url']) ? trim($_REQUEST['url'], '/') : false;
|
||||
$flush = (isset($_GET['flush']) || $requestURL === trim(BASE_URL . '/dev/build', '/'));
|
||||
|
||||
global $manifest;
|
||||
$manifest = new SS_ClassManifest(BASE_PATH, false, $flush);
|
||||
$manifest = new ClassManifest(BASE_PATH, false, $flush);
|
||||
|
||||
// Register SilverStripe's class map autoload
|
||||
$loader = SS_ClassLoader::instance();
|
||||
$loader = ClassLoader::instance();
|
||||
$loader->registerAutoloader();
|
||||
$loader->pushManifest($manifest);
|
||||
|
||||
// Now that the class manifest is up, load the static configuration
|
||||
$configManifest = new SS_ConfigStaticManifest();
|
||||
$configManifest = new ConfigStaticManifest();
|
||||
Config::inst()->pushConfigStaticManifest($configManifest);
|
||||
|
||||
// And then the yaml configuration
|
||||
$configManifest = new SS_ConfigManifest(BASE_PATH, false, $flush);
|
||||
$configManifest = new ConfigManifest(BASE_PATH, false, $flush);
|
||||
Config::inst()->pushConfigYamlManifest($configManifest);
|
||||
|
||||
// Load template manifest
|
||||
|
@ -9,20 +9,20 @@ use SilverStripe\Dev\Deprecation;
|
||||
* A class that handles loading classes and interfaces from a class manifest
|
||||
* instance.
|
||||
*/
|
||||
class SS_ClassLoader {
|
||||
class ClassLoader {
|
||||
|
||||
/**
|
||||
* @var SS_ClassLoader
|
||||
* @var ClassLoader
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* @var array Map of 'instance' (SS_ClassManifest) and other options.
|
||||
* @var array Map of 'instance' (ClassManifest) and other options.
|
||||
*/
|
||||
protected $manifests = array();
|
||||
|
||||
/**
|
||||
* @return SS_ClassLoader
|
||||
* @return ClassLoader
|
||||
*/
|
||||
public static function instance() {
|
||||
return self::$instance ? self::$instance : self::$instance = new self();
|
||||
@ -32,7 +32,7 @@ class SS_ClassLoader {
|
||||
* Returns the currently active class manifest instance that is used for
|
||||
* loading classes.
|
||||
*
|
||||
* @return SS_ClassManifest
|
||||
* @return ClassManifest
|
||||
*/
|
||||
public function getManifest() {
|
||||
return $this->manifests[count($this->manifests) - 1]['instance'];
|
||||
@ -48,16 +48,16 @@ class SS_ClassLoader {
|
||||
/**
|
||||
* Pushes a class manifest instance onto the top of the stack.
|
||||
*
|
||||
* @param SS_ClassManifest $manifest
|
||||
* @param ClassManifest $manifest
|
||||
* @param bool $exclusive Marks the manifest as exclusive. If set to FALSE, will
|
||||
* look for classes in earlier manifests as well.
|
||||
*/
|
||||
public function pushManifest(SS_ClassManifest $manifest, $exclusive = true) {
|
||||
public function pushManifest(ClassManifest $manifest, $exclusive = true) {
|
||||
$this->manifests[] = array('exclusive' => $exclusive, 'instance' => $manifest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SS_ClassManifest
|
||||
* @return ClassManifest
|
||||
*/
|
||||
public function popManifest() {
|
||||
$manifest = array_pop($this->manifests);
|
||||
@ -91,7 +91,7 @@ class SS_ClassLoader {
|
||||
*/
|
||||
public function getItemPath($class) {
|
||||
foreach(array_reverse($this->manifests) as $manifest) {
|
||||
/** @var SS_ClassManifest $manifestInst */
|
||||
/** @var ClassManifest $manifestInst */
|
||||
$manifestInst = $manifest['instance'];
|
||||
if ($path = $manifestInst->getItemPath($class)) {
|
||||
return $path;
|
||||
|
@ -14,7 +14,7 @@ use Exception;
|
||||
* - All implementors of an interface.
|
||||
* - All module configuration files.
|
||||
*/
|
||||
class SS_ClassManifest {
|
||||
class ClassManifest {
|
||||
|
||||
const CONF_FILE = '_config.php';
|
||||
const CONF_DIR = '_config';
|
||||
|
@ -4,10 +4,10 @@ namespace SilverStripe\Core\Manifest;
|
||||
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Config\SS_DAG;
|
||||
use SilverStripe\Core\Config\SS_DAG_CyclicException;
|
||||
use SilverStripe\Core\Config\DAG;
|
||||
use SilverStripe\Core\Config\DAG_CyclicException;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\SS_Cache;
|
||||
use SilverStripe\Core\Cache;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Traversable;
|
||||
use Zend_Cache_Core;
|
||||
@ -15,7 +15,7 @@ use Zend_Cache_Core;
|
||||
/**
|
||||
* A utility class which builds a manifest of configuration items
|
||||
*/
|
||||
class SS_ConfigManifest {
|
||||
class ConfigManifest {
|
||||
|
||||
/** @var string - The base path used when building the manifest */
|
||||
protected $base;
|
||||
@ -136,7 +136,7 @@ class SS_ConfigManifest {
|
||||
*/
|
||||
protected function getCache()
|
||||
{
|
||||
return SS_Cache::factory('SS_Configuration', 'Core', array(
|
||||
return Cache::factory('SS_Configuration', 'Core', array(
|
||||
'automatic_serialization' => true,
|
||||
'lifetime' => null
|
||||
));
|
||||
@ -365,7 +365,7 @@ class SS_ConfigManifest {
|
||||
$frags = $this->yamlConfigFragments;
|
||||
|
||||
// Build a directed graph
|
||||
$dag = new SS_DAG($frags);
|
||||
$dag = new DAG($frags);
|
||||
|
||||
foreach ($frags as $i => $frag) {
|
||||
foreach ($frags as $j => $otherfrag) {
|
||||
@ -381,7 +381,7 @@ class SS_ConfigManifest {
|
||||
try {
|
||||
$this->yamlConfigFragments = $dag->sort();
|
||||
}
|
||||
catch (SS_DAG_CyclicException $e) {
|
||||
catch (DAG_CyclicException $e) {
|
||||
|
||||
if (!Director::isLive() && isset($_REQUEST['debug'])) {
|
||||
$res = '<h1>Remaining config fragment graph</h1>';
|
||||
|
@ -7,7 +7,7 @@ use ReflectionClass;
|
||||
/**
|
||||
* Allows access to config values set on classes using private statics.
|
||||
*/
|
||||
class SS_ConfigStaticManifest {
|
||||
class ConfigStaticManifest {
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Core\Manifest;
|
||||
|
||||
use SilverStripe\Assets\SS_FileFinder;
|
||||
use SilverStripe\Assets\FileFinder;
|
||||
|
||||
/**
|
||||
* An extension to the default file finder with some extra filters to faciliate
|
||||
@ -13,7 +13,7 @@ use SilverStripe\Assets\SS_FileFinder;
|
||||
* - Module tests directories are skipped if the ignore_tests option is not
|
||||
* set to false.
|
||||
*/
|
||||
class ManifestFileFinder extends SS_FileFinder {
|
||||
class ManifestFileFinder extends FileFinder {
|
||||
|
||||
const CONFIG_FILE = '_config.php';
|
||||
const CONFIG_DIR = '_config';
|
||||
|
@ -4,11 +4,13 @@ namespace SilverStripe\Dev;
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
|
||||
/**
|
||||
* Backtrace helper
|
||||
*/
|
||||
class SS_Backtrace {
|
||||
class Backtrace {
|
||||
use Configurable;
|
||||
|
||||
/**
|
||||
* @var array Replaces all arguments with a '<filtered>' string,
|
||||
@ -66,9 +68,9 @@ class SS_Backtrace {
|
||||
*/
|
||||
public static function filter_backtrace($bt, $ignoredFunctions = null) {
|
||||
$defaultIgnoredFunctions = array(
|
||||
'SilverStripe\\Logging\\SS_Log::log',
|
||||
'SilverStripe\\Dev\\SS_Backtrace::backtrace',
|
||||
'SilverStripe\\Dev\\SS_Backtrace::filtered_backtrace',
|
||||
'SilverStripe\\Logging\\Log::log',
|
||||
'SilverStripe\\Dev\\Backtrace::backtrace',
|
||||
'SilverStripe\\Dev\\Backtrace::filtered_backtrace',
|
||||
'Zend_Log_Writer_Abstract->write',
|
||||
'Zend_Log->log',
|
||||
'Zend_Log->__call',
|
||||
@ -93,7 +95,7 @@ class SS_Backtrace {
|
||||
array_shift($bt);
|
||||
}
|
||||
|
||||
$ignoredArgs = Config::inst()->get('SilverStripe\\Dev\\SS_Backtrace', 'ignore_function_args');
|
||||
$ignoredArgs = static::config()->get('ignore_function_args');
|
||||
|
||||
// Filter out arguments
|
||||
foreach($bt as $i => $frame) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Dev;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Object;
|
||||
|
||||
/**
|
||||
@ -44,7 +44,7 @@ abstract class BuildTask extends Object {
|
||||
* Implement this method in the task subclass to
|
||||
* execute via the TaskRunner
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return
|
||||
*/
|
||||
abstract public function run($request);
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\Core\Object;
|
||||
* Class to facilitate command-line output.
|
||||
* Support less-trivial output stuff such as colours (on xterm-color)
|
||||
*/
|
||||
class SS_Cli extends Object {
|
||||
class CLI extends Object {
|
||||
/**
|
||||
* Returns true if the current STDOUT supports the use of colour control codes.
|
||||
*/
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Dev;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
|
||||
/**
|
||||
* A basic HTML wrapper for stylish rendering of a developement info view.
|
||||
@ -16,7 +16,7 @@ class CliDebugView extends DebugView
|
||||
/**
|
||||
* Render HTML header for development views
|
||||
*
|
||||
* @param SS_HTTPRequest $httpRequest
|
||||
* @param HTTPRequest $httpRequest
|
||||
* @return string
|
||||
*/
|
||||
public function renderHeader($httpRequest = null) {
|
||||
@ -45,8 +45,8 @@ class CliDebugView extends DebugView
|
||||
} else {
|
||||
$errorTypeTitle = self::$error_types[$errno]['title'];
|
||||
}
|
||||
$output = SS_Cli::text("ERROR [" . $errorTypeTitle . "]: $errstr\nIN $httpRequest\n", "red", null, true);
|
||||
$output .= SS_Cli::text("Line $errline in $errfile\n\n", "red");
|
||||
$output = CLI::text("ERROR [" . $errorTypeTitle . "]: $errstr\nIN $httpRequest\n", "red", null, true);
|
||||
$output .= CLI::text("Line $errline in $errfile\n\n", "red");
|
||||
|
||||
return $output;
|
||||
}
|
||||
@ -78,7 +78,7 @@ class CliDebugView extends DebugView
|
||||
*/
|
||||
public function renderTrace($trace = null) {
|
||||
$output = "Trace\n=====\n";
|
||||
$output .= SS_Backtrace::get_rendered_backtrace($trace ? $trace : debug_backtrace(), true);
|
||||
$output .= Backtrace::get_rendered_backtrace($trace ? $trace : debug_backtrace(), true);
|
||||
|
||||
return $output;
|
||||
}
|
||||
@ -102,9 +102,9 @@ class CliDebugView extends DebugView
|
||||
|
||||
public function renderVariable($val, $caller) {
|
||||
$output = PHP_EOL;
|
||||
$output .= SS_Cli::text(str_repeat('=', self::config()->columns), 'green');
|
||||
$output .= CLI::text(str_repeat('=', self::config()->columns), 'green');
|
||||
$output .= PHP_EOL;
|
||||
$output .= SS_Cli::text($this->formatCaller($caller), 'blue', null, true);
|
||||
$output .= CLI::text($this->formatCaller($caller), 'blue', null, true);
|
||||
$output .= PHP_EOL.PHP_EOL;
|
||||
if (is_string($val)) {
|
||||
$output .= wordwrap($val, self::config()->columns);
|
||||
@ -112,7 +112,7 @@ class CliDebugView extends DebugView
|
||||
$output .= var_export($val, true);
|
||||
}
|
||||
$output .= PHP_EOL;
|
||||
$output .= SS_Cli::text(str_repeat('=', self::config()->columns), 'green');
|
||||
$output .= CLI::text(str_repeat('=', self::config()->columns), 'green');
|
||||
$output .= PHP_EOL;
|
||||
|
||||
return $output;
|
||||
|
@ -50,15 +50,15 @@ class CliTestReporter extends SapphireTestReporter {
|
||||
echo "\n\n";
|
||||
$breakages = $errorCount + $failCount;
|
||||
if ($breakages == 0 && $incompleteCount > 0) {
|
||||
echo SS_Cli::text(" OK, BUT INCOMPLETE TESTS! ", "black", "yellow");
|
||||
echo CLI::text(" OK, BUT INCOMPLETE TESTS! ", "black", "yellow");
|
||||
} elseif ($breakages == 0) {
|
||||
echo SS_Cli::text(" ALL TESTS PASS ", "black", "green");
|
||||
echo CLI::text(" ALL TESTS PASS ", "black", "green");
|
||||
} else {
|
||||
echo SS_Cli::text(" AT LEAST ONE FAILURE ", "black", "red");
|
||||
echo CLI::text(" AT LEAST ONE FAILURE ", "black", "red");
|
||||
}
|
||||
|
||||
echo sprintf("\n\n%d tests run: %s, %s, and %s\n", $testCount, SS_Cli::text("$passCount passes"),
|
||||
SS_Cli::text("$breakages failures"), SS_Cli::text("$incompleteCount incomplete"));
|
||||
echo sprintf("\n\n%d tests run: %s, %s, and %s\n", $testCount, CLI::text("$passCount passes"),
|
||||
CLI::text("$breakages failures"), CLI::text("$incompleteCount incomplete"));
|
||||
|
||||
echo "Maximum memory usage: " . number_format(memory_get_peak_usage()/(1024*1024), 1) . "M\n\n";
|
||||
|
||||
@ -83,11 +83,11 @@ class CliTestReporter extends SapphireTestReporter {
|
||||
public function endTest( PHPUnit_Framework_Test $test, $time) {
|
||||
// Status indicator, a la PHPUnit
|
||||
switch($this->currentTest['status']) {
|
||||
case TEST_FAILURE: echo SS_Cli::text("F","red", null, true); break;
|
||||
case TEST_ERROR: echo SS_Cli::text("E","red", null, true); break;
|
||||
case TEST_INCOMPLETE: echo SS_Cli::text("I","yellow"); break;
|
||||
case TEST_SUCCESS: echo SS_Cli::text(".","green"); break;
|
||||
default: echo SS_Cli::text("?", "yellow"); break;
|
||||
case TEST_FAILURE: echo CLI::text("F","red", null, true); break;
|
||||
case TEST_ERROR: echo CLI::text("E","red", null, true); break;
|
||||
case TEST_INCOMPLETE: echo CLI::text("I","yellow"); break;
|
||||
case TEST_SUCCESS: echo CLI::text(".","green"); break;
|
||||
default: echo CLI::text("?", "yellow"); break;
|
||||
}
|
||||
|
||||
static $colCount = 0;
|
||||
@ -130,8 +130,8 @@ class CliTestReporter extends SapphireTestReporter {
|
||||
}
|
||||
|
||||
$color = ($test['status'] == 2) ? 'yellow' : 'red';
|
||||
echo "\n" . SS_Cli::text($test['name'] . "\n". $test['message'] . "\n", $color, null);
|
||||
echo SS_Backtrace::get_rendered_backtrace($filteredTrace, true);
|
||||
echo "\n" . CLI::text($test['name'] . "\n". $test['message'] . "\n", $color, null);
|
||||
echo Backtrace::get_rendered_backtrace($filteredTrace, true);
|
||||
echo "--------------------\n";
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Dev;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Object;
|
||||
|
||||
@ -192,7 +192,7 @@ class DebugView extends Object
|
||||
/**
|
||||
* Render HTML header for development views
|
||||
*
|
||||
* @param SS_HTTPRequest $httpRequest
|
||||
* @param HTTPRequest $httpRequest
|
||||
* @return string
|
||||
*/
|
||||
public function renderHeader($httpRequest = null) {
|
||||
@ -304,7 +304,7 @@ class DebugView extends Object
|
||||
*/
|
||||
public function renderTrace($trace) {
|
||||
$output = '<h3>Trace</h3>';
|
||||
$output .= SS_Backtrace::get_rendered_backtrace($trace);
|
||||
$output .= Backtrace::get_rendered_backtrace($trace);
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Dev;
|
||||
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
|
||||
/**
|
||||
* Handles raising an notice when accessing a deprecated method
|
||||
@ -104,7 +104,7 @@ class Deprecation {
|
||||
|
||||
$callingfile = realpath($backtrace[1]['file']);
|
||||
|
||||
$manifest = SS_ClassLoader::instance()->getManifest();
|
||||
$manifest = ClassLoader::instance()->getManifest();
|
||||
foreach ($manifest->getModules() as $name => $path) {
|
||||
if (strpos($callingfile, realpath($path)) === 0) {
|
||||
return $name;
|
||||
|
@ -5,8 +5,8 @@ namespace SilverStripe\Dev;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\ORM\Versioning\Versioned;
|
||||
use SilverStripe\ORM\DatabaseAdmin;
|
||||
@ -123,7 +123,7 @@ class DevelopmentAdmin extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function runRegisteredController(SS_HTTPRequest $request){
|
||||
public function runRegisteredController(HTTPRequest $request){
|
||||
$controllerClass = null;
|
||||
|
||||
$baseUrlPart = $request->param('Action');
|
||||
@ -224,7 +224,7 @@ Security:
|
||||
token: $token
|
||||
|
||||
TXT;
|
||||
$response = new SS_HTTPResponse($body);
|
||||
$response = new HTTPResponse($body);
|
||||
return $response->addHeader('Content-Type', 'text/plain');
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Dev;
|
||||
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Security\BasicAuth;
|
||||
use SilverStripe\Security\Member;
|
||||
@ -143,7 +143,7 @@ class FunctionalTest extends SapphireTest {
|
||||
* @param Session $session
|
||||
* @param array $headers
|
||||
* @param array $cookies
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function get($url, $session = null, $headers = null, $cookies = null) {
|
||||
$this->cssParser = null;
|
||||
@ -164,7 +164,7 @@ class FunctionalTest extends SapphireTest {
|
||||
* @param Session $session
|
||||
* @param string $body
|
||||
* @param array $cookies
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function post($url, $data, $headers = null, $session = null, $body = null, $cookies = null) {
|
||||
$this->cssParser = null;
|
||||
@ -192,7 +192,7 @@ class FunctionalTest extends SapphireTest {
|
||||
* @param string $formID HTML 'id' attribute of a form (loaded through a previous response)
|
||||
* @param string $button HTML 'name' attribute of the button (NOT the 'id' attribute)
|
||||
* @param array $data Map of GET/POST data.
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function submitForm($formID, $button = null, $data = array()) {
|
||||
$this->cssParser = null;
|
||||
|
@ -55,10 +55,10 @@ class SapphireREPL extends Controller {
|
||||
|
||||
echo "SilverStripe Interactive Command-line (REPL interface). Type help for hints.\n\n";
|
||||
while(true) {
|
||||
echo SS_Cli::text("?> ", "cyan");
|
||||
echo SS_Cli::start_colour("yellow");
|
||||
echo CLI::text("?> ", "cyan");
|
||||
echo CLI::start_colour("yellow");
|
||||
$command = trim(fgets(STDIN, 4096));
|
||||
echo SS_Cli::end_colour();
|
||||
echo CLI::end_colour();
|
||||
|
||||
if ( $command == 'help' || $command == '?' ) {
|
||||
print "help or ? to exit\n" ;
|
||||
@ -83,7 +83,7 @@ class SapphireREPL extends Controller {
|
||||
echo "\n";
|
||||
}
|
||||
catch( Exception $__repl_exception ) {
|
||||
echo SS_Cli::start_colour("red");
|
||||
echo CLI::start_colour("red");
|
||||
printf( '%s (code: %d) got thrown'.PHP_EOL,
|
||||
get_class($__repl_exception),
|
||||
$__repl_exception->getCode() );
|
||||
|
@ -12,9 +12,9 @@ use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\Manifest\SS_ClassManifest;
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\SS_ConfigStaticManifest;
|
||||
use SilverStripe\Core\Manifest\ClassManifest;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ConfigStaticManifest;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\Versioning\Versioned;
|
||||
@ -100,7 +100,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
protected static $is_running_test = false;
|
||||
|
||||
/**
|
||||
* @var SS_ClassManifest
|
||||
* @var ClassManifest
|
||||
*/
|
||||
protected static $test_class_manifest;
|
||||
|
||||
@ -178,7 +178,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
* Set the manifest to be used to look up test classes by helper functions
|
||||
*
|
||||
* @param SS_ClassManifest $manifest
|
||||
* @param ClassManifest $manifest
|
||||
*/
|
||||
public static function set_test_class_manifest($manifest) {
|
||||
self::$test_class_manifest = $manifest;
|
||||
@ -187,7 +187,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
* Return the manifest being used to look up test classes by helper functions
|
||||
*
|
||||
* @return SS_ClassManifest
|
||||
* @return ClassManifest
|
||||
*/
|
||||
public static function get_test_class_manifest() {
|
||||
return self::$test_class_manifest;
|
||||
@ -886,18 +886,18 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
$flush = false;
|
||||
}
|
||||
|
||||
$classManifest = new SS_ClassManifest(
|
||||
$classManifest = new ClassManifest(
|
||||
BASE_PATH, true, $flush
|
||||
);
|
||||
|
||||
SS_ClassLoader::instance()->pushManifest($classManifest, false);
|
||||
ClassLoader::instance()->pushManifest($classManifest, false);
|
||||
SapphireTest::set_test_class_manifest($classManifest);
|
||||
|
||||
ThemeResourceLoader::instance()->addSet('$default', new ThemeManifest(
|
||||
BASE_PATH, project(), true, $flush
|
||||
));
|
||||
|
||||
Config::inst()->pushConfigStaticManifest(new SS_ConfigStaticManifest(
|
||||
Config::inst()->pushConfigStaticManifest(new ConfigStaticManifest(
|
||||
BASE_PATH, true, $flush
|
||||
));
|
||||
|
||||
|
@ -378,7 +378,7 @@ class SapphireTestReporter implements PHPUnit_Framework_TestListener {
|
||||
protected function writeResultError($name, $message, $trace) {
|
||||
echo "<div class=\"failure\"><h2 class=\"test-case\">⊗ ". $this->testNameToPhrase($name) ."</h2>";
|
||||
echo "<pre>".htmlentities($message, ENT_COMPAT, 'UTF-8')."</pre>";
|
||||
echo SS_Backtrace::get_rendered_backtrace($trace);
|
||||
echo Backtrace::get_rendered_backtrace($trace);
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Dev;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
@ -71,7 +71,7 @@ class TaskRunner extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
*/
|
||||
public function runTask($request) {
|
||||
$name = $request->param('TaskName');
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Dev\Tasks;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\Debug;
|
||||
use SilverStripe\Dev\BuildTask;
|
||||
@ -35,7 +35,7 @@ class i18nTextCollectorTask extends BuildTask {
|
||||
*
|
||||
* @uses DataObject->collectI18nStatics()
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
*/
|
||||
public function run($request) {
|
||||
increase_time_limit_to();
|
||||
@ -63,7 +63,7 @@ class i18nTextCollectorTask extends BuildTask {
|
||||
/**
|
||||
* Check if we should merge
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
protected function getIsMerge($request) {
|
||||
|
@ -4,9 +4,9 @@ namespace SilverStripe\Dev;
|
||||
|
||||
use PHPUnit_Framework_TestListener;
|
||||
use PHPUnit_Framework_Test;
|
||||
use Exception;
|
||||
use PHPUnit_Framework_AssertionFailedError;
|
||||
use PHPUnit_Framework_TestSuite;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Necessary to call setUpOnce() and tearDownOnce() on {@link SapphireTest}
|
||||
@ -15,7 +15,7 @@ use PHPUnit_Framework_TestSuite;
|
||||
*
|
||||
* @see http://www.phpunit.de/manual/3.5/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener
|
||||
*/
|
||||
class SS_TestListener implements PHPUnit_Framework_TestListener {
|
||||
class TestListener implements PHPUnit_Framework_TestListener {
|
||||
|
||||
/**
|
||||
* @var SapphireTest
|
@ -6,7 +6,7 @@ use SilverStripe\Control\Cookie_Backend;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SimpleByName;
|
||||
use Exception;
|
||||
@ -30,7 +30,7 @@ class TestSession {
|
||||
private $cookies;
|
||||
|
||||
/**
|
||||
* @var SS_HTTPResponse
|
||||
* @var HTTPResponse
|
||||
*/
|
||||
private $lastResponse;
|
||||
|
||||
@ -74,7 +74,7 @@ class TestSession {
|
||||
* @param Session $session
|
||||
* @param array $headers
|
||||
* @param array $cookies
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function get($url, $session = null, $headers = null, $cookies = null) {
|
||||
$headers = (array) $headers;
|
||||
@ -103,7 +103,7 @@ class TestSession {
|
||||
* @param Session $session
|
||||
* @param string $body
|
||||
* @param array $cookies
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function post($url, $data, $headers = null, $session = null, $body = null, $cookies = null) {
|
||||
$headers = (array) $headers;
|
||||
@ -139,7 +139,7 @@ class TestSession {
|
||||
* @param string $formID HTML 'id' attribute of a form (loaded through a previous response)
|
||||
* @param string $button HTML 'name' attribute of the button (NOT the 'id' attribute)
|
||||
* @param array $data Map of GET/POST data.
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
* @throws Exception
|
||||
*/
|
||||
public function submitForm($formID, $button = null, $data = array()) {
|
||||
@ -176,7 +176,7 @@ class TestSession {
|
||||
/**
|
||||
* If the last request was a 3xx response, then follow the redirection
|
||||
*
|
||||
* @return SS_HTTPResponse The response given, or null if no redirect occurred
|
||||
* @return HTTPResponse The response given, or null if no redirect occurred
|
||||
*/
|
||||
public function followRedirection() {
|
||||
if($this->lastResponse->getHeader('Location')) {
|
||||
@ -199,7 +199,7 @@ class TestSession {
|
||||
/**
|
||||
* Get the most recent response
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function lastResponse() {
|
||||
return $this->lastResponse;
|
||||
|
@ -2,20 +2,20 @@
|
||||
|
||||
namespace SilverStripe\Dev;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
|
||||
/**
|
||||
* Wrapper around SS_HTTPResponse to make it look like a SimpleHTTPResposne
|
||||
* Wrapper around HTTPResponse to make it look like a SimpleHTTPResposne
|
||||
*/
|
||||
class TestSession_STResponseWrapper
|
||||
{
|
||||
|
||||
/**
|
||||
* @var SS_HTTPResponse
|
||||
* @var HTTPResponse
|
||||
*/
|
||||
private $response;
|
||||
|
||||
public function __construct(SS_HTTPResponse $response)
|
||||
public function __construct(HTTPResponse $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\View\Requirements;
|
||||
use Exception;
|
||||
|
||||
@ -708,10 +708,10 @@ class AssetField extends FileField {
|
||||
/**
|
||||
* Action to handle upload of a single file
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function upload(SS_HTTPRequest $request) {
|
||||
public function upload(HTTPRequest $request) {
|
||||
if($this->isDisabled() || $this->isReadonly() || !$this->canUpload()) {
|
||||
return $this->httpError(403);
|
||||
}
|
||||
@ -747,7 +747,7 @@ class AssetField extends FileField {
|
||||
->clearErrors();
|
||||
|
||||
// Format response with json
|
||||
$response = new SS_HTTPResponse(Convert::raw2json(array($return)));
|
||||
$response = new HTTPResponse(Convert::raw2json(array($return)));
|
||||
$response->addHeader('Content-Type', 'text/plain');
|
||||
return $response;
|
||||
}
|
||||
|
@ -3,13 +3,13 @@
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\HTTP;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
@ -359,8 +359,8 @@ class Form extends RequestHandler {
|
||||
* and only triggers the requested form action/method
|
||||
* if the form is valid.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @param HTTPRequest $request
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public function httpSubmission($request) {
|
||||
// Strict method check
|
||||
@ -550,7 +550,7 @@ class Form extends RequestHandler {
|
||||
* Behaviour can be influenced by setting {@link $redirectToFormOnValidationError},
|
||||
* and can be overruled by setting {@link $validationResponseCallback}.
|
||||
*
|
||||
* @return SS_HTTPResponse|string
|
||||
* @return HTTPResponse|string
|
||||
*/
|
||||
protected function getValidationErrorResponse() {
|
||||
$callback = $this->getValidationResponseCallback();
|
||||
@ -565,12 +565,12 @@ class Form extends RequestHandler {
|
||||
$acceptType = $request->getHeader('Accept');
|
||||
if(strpos($acceptType, 'application/json') !== FALSE) {
|
||||
// Send validation errors back as JSON with a flag at the start
|
||||
$response = new SS_HTTPResponse(Convert::array2json($this->validator->getErrors()));
|
||||
$response = new HTTPResponse(Convert::array2json($this->validator->getErrors()));
|
||||
$response->addHeader('Content-Type', 'application/json');
|
||||
} else {
|
||||
$this->setupFormErrors();
|
||||
// Send the newly rendered form tag as HTML
|
||||
$response = new SS_HTTPResponse($this->forTemplate());
|
||||
$response = new HTTPResponse($this->forTemplate());
|
||||
$response->addHeader('Content-Type', 'text/html');
|
||||
}
|
||||
|
||||
@ -619,7 +619,7 @@ class Form extends RequestHandler {
|
||||
* formfield with the same name, this method gives priority
|
||||
* to the formfield.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return FormField
|
||||
*/
|
||||
public function handleField($request) {
|
||||
@ -1863,9 +1863,9 @@ class Form extends RequestHandler {
|
||||
* Test a submission of this form.
|
||||
* @param string $action
|
||||
* @param array $data
|
||||
* @return SS_HTTPResponse the response object that the handling controller produces. You can interrogate this in
|
||||
* @return HTTPResponse the response object that the handling controller produces. You can interrogate this in
|
||||
* your unit test.
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public function testSubmission($action, $data) {
|
||||
$data['action_' . $action] = true;
|
||||
@ -1878,7 +1878,7 @@ class Form extends RequestHandler {
|
||||
*
|
||||
* @param string $action
|
||||
* @param array $data
|
||||
* @return SS_HTTPResponse the response object that the handling controller produces. You can interrogate this in
|
||||
* @return HTTPResponse the response object that the handling controller produces. You can interrogate this in
|
||||
* your unit test.
|
||||
*/
|
||||
public function testAjaxSubmission($action, $data) {
|
||||
|
@ -9,10 +9,10 @@ use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\DataModel;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\Forms\Form;
|
||||
@ -135,7 +135,7 @@ class GridField extends FormField {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -852,11 +852,11 @@ class GridField extends FormField {
|
||||
*
|
||||
* @param array $data
|
||||
* @param Form $form
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function gridFieldAlterAction($data, $form, SS_HTTPRequest $request) {
|
||||
public function gridFieldAlterAction($data, $form, HTTPRequest $request) {
|
||||
$data = $request->requestVars();
|
||||
|
||||
// Protection against CSRF attacks
|
||||
@ -947,14 +947,14 @@ class GridField extends FormField {
|
||||
*
|
||||
* @todo copy less code from RequestHandler.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @param DataModel $model
|
||||
*
|
||||
* @return array|RequestHandler|SS_HTTPResponse|string|void
|
||||
* @return array|RequestHandler|HTTPResponse|string|void
|
||||
*
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||
public function handleRequest(HTTPRequest $request, DataModel $model) {
|
||||
if($this->brokenOnConstruct) {
|
||||
user_error(
|
||||
sprintf(
|
||||
@ -1000,11 +1000,11 @@ class GridField extends FormField {
|
||||
|
||||
try {
|
||||
$result = $component->$action($this, $request);
|
||||
} catch(SS_HTTPResponse_Exception $responseException) {
|
||||
} catch(HTTPResponse_Exception $responseException) {
|
||||
$result = $responseException->getResponse();
|
||||
}
|
||||
|
||||
if($result instanceof SS_HTTPResponse && $result->isError()) {
|
||||
if($result instanceof HTTPResponse && $result->isError()) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\Controller;
|
||||
@ -201,7 +201,7 @@ class GridFieldAddExistingAutocompleter
|
||||
* Returns a json array of a search results that can be used by for example Jquery.ui.autosuggestion
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return string
|
||||
*/
|
||||
public function doSearch($gridField, $request) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Extensible;
|
||||
use SilverStripe\ORM\DataModel;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
@ -87,7 +87,7 @@ class GridFieldDetailForm implements GridField_URLHandler {
|
||||
/**
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return GridFieldDetailForm_ItemRequest
|
||||
*/
|
||||
public function handleItem($gridField, $request) {
|
||||
|
@ -6,9 +6,9 @@ use SilverStripe\Admin\LeftAndMain;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\PjaxResponseNegotiator;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\FormAction;
|
||||
@ -99,7 +99,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function view($request)
|
||||
@ -127,7 +127,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit($request)
|
||||
@ -425,7 +425,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
* Response object for this request after a successful save
|
||||
*
|
||||
* @param bool $isNewRecord True if this record was just created
|
||||
* @return SS_HTTPResponse|DBHTMLText
|
||||
* @return HTTPResponse|DBHTMLText
|
||||
*/
|
||||
protected function redirectAfterSave($isNewRecord)
|
||||
{
|
||||
@ -489,8 +489,8 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
*
|
||||
* @param Form $form The source form
|
||||
* @param ValidationException $e The validation error message
|
||||
* @return SS_HTTPResponse
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @return HTTPResponse
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
protected function generateValidationResponse($form, $e)
|
||||
{
|
||||
@ -514,7 +514,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
/**
|
||||
* @param array $data
|
||||
* @param Form $form
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function doDelete($data, $form)
|
||||
{
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
/**
|
||||
@ -101,15 +101,15 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
|
||||
* Handle the export, for both the action button and the URL
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function handleExport($gridField, $request = null) {
|
||||
$now = date("d-m-Y-H-i");
|
||||
$fileName = "export-$now.csv";
|
||||
|
||||
if($fileData = $this->generateExportFileData($gridField)){
|
||||
return SS_HTTPRequest::send_file($fileData, $fileName, 'text/csv');
|
||||
return HTTPRequest::send_file($fileData, $fileName, 'text/csv');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Forms\FieldGroup;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\SS_Filterable;
|
||||
use SilverStripe\ORM\Filterable;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
@ -56,7 +56,7 @@ class GridFieldFilterHeader implements GridField_HTMLProvider, GridField_DataMan
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkDataType($dataList) {
|
||||
if($dataList instanceof SS_Filterable) {
|
||||
if($dataList instanceof Filterable) {
|
||||
return true;
|
||||
} else {
|
||||
if($this->throwExceptionOnBadDataType) {
|
||||
@ -107,7 +107,7 @@ class GridFieldFilterHeader implements GridField_HTMLProvider, GridField_DataMan
|
||||
return $dataList;
|
||||
}
|
||||
|
||||
/** @var SS_Filterable $dataList */
|
||||
/** @var Filterable $dataList */
|
||||
/** @var GridState_Data $columns */
|
||||
$columns = $gridField->State->GridFieldFilterHeader->Columns(null);
|
||||
if(empty($columns)) {
|
||||
@ -130,7 +130,7 @@ class GridFieldFilterHeader implements GridField_HTMLProvider, GridField_DataMan
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var SS_Filterable $list */
|
||||
/** @var Filterable $list */
|
||||
$forTemplate = new ArrayData(array());
|
||||
$forTemplate->Fields = new ArrayList;
|
||||
$columns = $gridField->getColumns();
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\ORM\SS_Limitable;
|
||||
use SilverStripe\ORM\Limitable;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\UnsavedRelationList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
@ -77,7 +77,7 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkDataType($dataList) {
|
||||
if($dataList instanceof SS_Limitable) {
|
||||
if($dataList instanceof Limitable) {
|
||||
return true;
|
||||
} else {
|
||||
if($this->throwExceptionOnBadDataType) {
|
||||
@ -158,7 +158,7 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu
|
||||
$startRow = 0;
|
||||
}
|
||||
|
||||
if(!($dataList instanceof SS_Limitable) || ($dataList instanceof UnsavedRelationList)) {
|
||||
if(!($dataList instanceof Limitable) || ($dataList instanceof UnsavedRelationList)) {
|
||||
return $dataList;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
@ -113,7 +113,7 @@ class GridFieldPrintButton implements GridField_HTMLProvider, GridField_ActionPr
|
||||
* Handle the print, for both the action button and the URL
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return DBHTMLText
|
||||
*/
|
||||
public function handlePrint($gridField, $request = null) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Forms\LiteralField;
|
||||
use SilverStripe\ORM\SS_Sortable;
|
||||
use SilverStripe\ORM\Sortable;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
@ -65,7 +65,7 @@ class GridFieldSortableHeader implements GridField_HTMLProvider, GridField_DataM
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkDataType($dataList) {
|
||||
if($dataList instanceof SS_Sortable) {
|
||||
if($dataList instanceof Sortable) {
|
||||
return true;
|
||||
} else {
|
||||
if($this->throwExceptionOnBadDataType) {
|
||||
@ -106,7 +106,7 @@ class GridFieldSortableHeader implements GridField_HTMLProvider, GridField_DataM
|
||||
if(!$this->checkDataType($list)) {
|
||||
return null;
|
||||
}
|
||||
/** @var SS_Sortable $list */
|
||||
/** @var Sortable $list */
|
||||
$forTemplate = new ArrayData(array());
|
||||
$forTemplate->Fields = new ArrayList;
|
||||
|
||||
@ -237,7 +237,7 @@ class GridFieldSortableHeader implements GridField_HTMLProvider, GridField_DataM
|
||||
return $dataList;
|
||||
}
|
||||
|
||||
/** @var SS_Sortable $dataList */
|
||||
/** @var Sortable $dataList */
|
||||
$state = $gridField->State->GridFieldSortableHeader;
|
||||
if ($state->SortColumn == "") {
|
||||
return $dataList;
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Forms\HTMLEditor;
|
||||
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use Embed\Adapters\AdapterInterface;
|
||||
@ -46,7 +46,7 @@ class HTMLEditorField_Embed extends HTMLEditorField_File
|
||||
)));
|
||||
$response->setStatusCode(404);
|
||||
|
||||
throw new SS_HTTPResponse_Exception($response);
|
||||
throw new HTTPResponse_Exception($response);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@ use SilverStripe\Assets\Upload;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Forms\CheckboxField;
|
||||
use SilverStripe\Forms\CompositeField;
|
||||
use SilverStripe\Forms\EmailField;
|
||||
@ -355,7 +355,7 @@ class HTMLEditorField_Toolbar extends RequestHandler
|
||||
*
|
||||
* @param string $fileUrl Absolute URL
|
||||
* @return array
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
protected function viewfile_getRemoteFileByURL($fileUrl)
|
||||
{
|
||||
@ -389,11 +389,11 @@ class HTMLEditorField_Toolbar extends RequestHandler
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @return SS_HTTPResponse_Exception
|
||||
* @return HTTPResponse_Exception
|
||||
*/
|
||||
protected function getErrorFor($message, $code = 400)
|
||||
{
|
||||
$exception = new SS_HTTPResponse_Exception($message, $code);
|
||||
$exception = new HTTPResponse_Exception($message, $code);
|
||||
$exception->getResponse()->addHeader('X-Status', $message);
|
||||
return $exception;
|
||||
}
|
||||
@ -401,8 +401,8 @@ class HTMLEditorField_Toolbar extends RequestHandler
|
||||
/**
|
||||
* View of a single file, either on the filesystem or on the web.
|
||||
*
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @param SS_HTTPRequest $request
|
||||
* @throws HTTPResponse_Exception
|
||||
* @param HTTPRequest $request
|
||||
* @return string
|
||||
*/
|
||||
public function viewfile($request)
|
||||
@ -488,7 +488,7 @@ class HTMLEditorField_Toolbar extends RequestHandler
|
||||
* Find all anchors available on the given page.
|
||||
*
|
||||
* @return array
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public function getanchors()
|
||||
{
|
||||
@ -497,7 +497,7 @@ class HTMLEditorField_Toolbar extends RequestHandler
|
||||
|
||||
if (($page = Page::get()->byID($id)) && !empty($page)) {
|
||||
if (!$page->canView()) {
|
||||
throw new SS_HTTPResponse_Exception(
|
||||
throw new HTTPResponse_Exception(
|
||||
_t(
|
||||
'HTMLEditorField.ANCHORSCANNOTACCESSPAGE',
|
||||
'You are not permitted to access the content of the target page.'
|
||||
@ -521,7 +521,7 @@ class HTMLEditorField_Toolbar extends RequestHandler
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new SS_HTTPResponse_Exception(
|
||||
throw new HTTPResponse_Exception(
|
||||
_t('HTMLEditorField.ANCHORSPAGENOTFOUND', 'Target page not found.'),
|
||||
404
|
||||
);
|
||||
|
@ -6,7 +6,7 @@ use DOMAttr;
|
||||
use DOMElement;
|
||||
use DOMNode;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\View\Parsers\SS_HTMLValue;
|
||||
use SilverStripe\View\Parsers\HTMLValue;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
@ -268,9 +268,9 @@ class HTMLEditorSanitiser {
|
||||
* Given an SS_HTMLValue instance, will remove and elements and attributes that are
|
||||
* not explicitly included in the whitelist passed to __construct on instance creation
|
||||
*
|
||||
* @param SS_HTMLValue $html - The HTMLValue to remove any non-whitelisted elements & attributes from
|
||||
* @param HTMLValue $html - The HTMLValue to remove any non-whitelisted elements & attributes from
|
||||
*/
|
||||
public function sanitise (SS_HTMLValue $html) {
|
||||
public function sanitise (HTMLValue $html) {
|
||||
if(!$this->elements && !$this->elementPatterns) return;
|
||||
|
||||
$doc = $html->getDocument();
|
||||
|
@ -35,7 +35,7 @@ use SilverStripe\View\ArrayData;
|
||||
* <code>
|
||||
* //Database request for the object
|
||||
* $map = FooBar::get()->map();
|
||||
* // returns an SS_Map object containing an array of ID => Title
|
||||
* // returns a Map object containing an array of ID => Title
|
||||
*
|
||||
* // Instantiate the OptionsetField
|
||||
* $FieldList = new FieldList(
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\SS_Map;
|
||||
use SilverStripe\ORM\Map;
|
||||
use ArrayAccess;
|
||||
|
||||
/**
|
||||
@ -157,7 +157,7 @@ abstract class SelectField extends FormField {
|
||||
if($source instanceof SS_List) {
|
||||
$source = $source->map();
|
||||
}
|
||||
if($source instanceof SS_Map) {
|
||||
if($source instanceof Map) {
|
||||
$source = $source->toArray();
|
||||
}
|
||||
if(!is_array($source) && !($source instanceof ArrayAccess)) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
@ -276,11 +276,11 @@ class TreeDropdownField extends FormField {
|
||||
/**
|
||||
* Get the whole tree of a part of the tree via an AJAX request.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function tree(SS_HTTPRequest $request) {
|
||||
public function tree(HTTPRequest $request) {
|
||||
// Array sourceObject is an explicit list of values - construct a "flat tree"
|
||||
if(is_array($this->sourceObject)) {
|
||||
$output = "<ul class=\"tree\">\n";
|
||||
|
@ -6,8 +6,8 @@ use SilverStripe\Assets\Storage\AssetContainer;
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Assets\FileNameFilter;
|
||||
use SilverStripe\Assets\Folder;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
@ -1093,10 +1093,10 @@ class UploadField extends FileField {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return UploadField_ItemHandler
|
||||
*/
|
||||
public function handleItem(SS_HTTPRequest $request) {
|
||||
public function handleItem(HTTPRequest $request) {
|
||||
return $this->getItemHandler($request->param('ID'));
|
||||
}
|
||||
|
||||
@ -1109,10 +1109,10 @@ class UploadField extends FileField {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return UploadField_SelectHandler
|
||||
*/
|
||||
public function handleSelect(SS_HTTPRequest $request) {
|
||||
public function handleSelect(HTTPRequest $request) {
|
||||
if(!$this->canAttachExisting()) {
|
||||
return $this->httpError(403);
|
||||
}
|
||||
@ -1234,11 +1234,11 @@ class UploadField extends FileField {
|
||||
/**
|
||||
* Action to handle upload of a single file
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function upload(SS_HTTPRequest $request) {
|
||||
public function upload(HTTPRequest $request) {
|
||||
if($this->isDisabled() || $this->isReadonly() || !$this->canUpload()) {
|
||||
return $this->httpError(403);
|
||||
}
|
||||
@ -1268,7 +1268,7 @@ class UploadField extends FileField {
|
||||
}
|
||||
|
||||
// Format response with json
|
||||
$response = new SS_HTTPResponse(Convert::raw2json($return));
|
||||
$response = new HTTPResponse(Convert::raw2json($return));
|
||||
$response->addHeader('Content-Type', 'text/plain');
|
||||
return $response;
|
||||
}
|
||||
@ -1277,10 +1277,10 @@ class UploadField extends FileField {
|
||||
* Retrieves details for files that this field wishes to attache to the
|
||||
* client-side form
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function attach(SS_HTTPRequest $request) {
|
||||
public function attach(HTTPRequest $request) {
|
||||
if(!$request->isPOST()) return $this->httpError(403);
|
||||
if(!$this->canAttachExisting()) return $this->httpError(403);
|
||||
|
||||
@ -1290,7 +1290,7 @@ class UploadField extends FileField {
|
||||
foreach($files as $file) {
|
||||
$return[] = $this->encodeFileAttributes($file);
|
||||
}
|
||||
$response = new SS_HTTPResponse(Convert::raw2json($return));
|
||||
$response = new HTTPResponse(Convert::raw2json($return));
|
||||
$response->addHeader('Content-Type', 'application/json');
|
||||
return $response;
|
||||
}
|
||||
@ -1319,10 +1319,10 @@ class UploadField extends FileField {
|
||||
/**
|
||||
* Determines if a specified file exists
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function fileexists(SS_HTTPRequest $request) {
|
||||
public function fileexists(HTTPRequest $request) {
|
||||
// Assert that requested filename doesn't attempt to escape the directory
|
||||
$originalFile = $request->requestVar('filename');
|
||||
if($originalFile !== basename($originalFile)) {
|
||||
@ -1336,7 +1336,7 @@ class UploadField extends FileField {
|
||||
}
|
||||
|
||||
// Encode and present response
|
||||
$response = new SS_HTTPResponse(Convert::raw2json($return));
|
||||
$response = new HTTPResponse(Convert::raw2json($return));
|
||||
$response->addHeader('Content-Type', 'application/json');
|
||||
if (!empty($return['error'])) $response->setStatusCode(400);
|
||||
return $response;
|
||||
|
@ -6,8 +6,8 @@ use SilverStripe\Assets\File;
|
||||
use SilverStripe\Assets\Folder;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\View\Requirements;
|
||||
@ -90,10 +90,10 @@ class UploadField_ItemHandler extends RequestHandler
|
||||
/**
|
||||
* Action to handle deleting of a single file
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function delete(SS_HTTPRequest $request)
|
||||
public function delete(HTTPRequest $request)
|
||||
{
|
||||
// Check form field state
|
||||
if ($this->parent->isDisabled() || $this->parent->isReadonly()) {
|
||||
@ -125,10 +125,10 @@ class UploadField_ItemHandler extends RequestHandler
|
||||
/**
|
||||
* Action to handle editing of a single file
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return DBHTMLText
|
||||
*/
|
||||
public function edit(SS_HTTPRequest $request)
|
||||
public function edit(HTTPRequest $request)
|
||||
{
|
||||
// Check form field state
|
||||
if ($this->parent->isDisabled() || $this->parent->isReadonly()) {
|
||||
@ -190,10 +190,10 @@ class UploadField_ItemHandler extends RequestHandler
|
||||
/**
|
||||
* @param array $data
|
||||
* @param Form $form
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return DBHTMLText
|
||||
*/
|
||||
public function doEdit(array $data, Form $form, SS_HTTPRequest $request)
|
||||
public function doEdit(array $data, Form $form, HTTPRequest $request)
|
||||
{
|
||||
// Check form field state
|
||||
if ($this->parent->isDisabled() || $this->parent->isReadonly()) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Logging;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use Monolog\Handler\AbstractProcessingHandler;
|
||||
|
||||
/**
|
||||
@ -77,7 +77,7 @@ class HTTPOutputHandler extends AbstractProcessingHandler
|
||||
if(Controller::has_curr()) {
|
||||
$response = Controller::curr()->getResponse();
|
||||
} else {
|
||||
$response = new SS_HTTPResponse();
|
||||
$response = new HTTPResponse();
|
||||
}
|
||||
|
||||
// If headers have been sent then these won't be used, and may throw errors that we wont' want to see.
|
||||
|
@ -13,42 +13,42 @@ use SilverStripe\Dev\Deprecation;
|
||||
* subclasses for output.
|
||||
*
|
||||
* These priorities are currently supported:
|
||||
* - SS_Log::ERR
|
||||
* - SS_Log::WARN
|
||||
* - SS_Log::NOTICE
|
||||
* - SS_Log::INFO
|
||||
* - SS_Log::DEBUG
|
||||
* - Log::ERR
|
||||
* - Log::WARN
|
||||
* - Log::NOTICE
|
||||
* - Log::INFO
|
||||
* - Log::DEBUG
|
||||
*
|
||||
* You can add an error writer by calling {@link SS_Log::add_writer()}
|
||||
* You can add an error writer by calling {@link Log::add_writer()}
|
||||
*
|
||||
* Example usage of logging errors by email notification:
|
||||
* <code>
|
||||
* SS_Log::add_writer(new SS_LogEmailWriter('my@email.com'), SS_Log::ERR);
|
||||
* Log::add_writer(new LogEmailWriter('my@email.com'), Log::ERR);
|
||||
* </code>
|
||||
*
|
||||
* Example usage of logging errors by file:
|
||||
* <code>
|
||||
* SS_Log::add_writer(new SS_LogFileWriter('/var/log/silverstripe/errors.log'), SS_Log::ERR);
|
||||
* Log::add_writer(new LogFileWriter('/var/log/silverstripe/errors.log'), Log::ERR);
|
||||
* </code>
|
||||
*
|
||||
* Example usage of logging at warnings and errors by setting the priority to '<=':
|
||||
* <code>
|
||||
* SS_Log::add_writer(new SS_LogEmailWriter('my@email.com'), SS_Log::WARN, '<=');
|
||||
* Log::add_writer(new LogEmailWriter('my@email.com'), Log::WARN, '<=');
|
||||
* </code>
|
||||
*
|
||||
* Each writer object can be assigned a formatter. The formatter is
|
||||
* responsible for formatting the message before giving it to the writer.
|
||||
* {@link SS_LogErrorEmailFormatter} is such an example that formats errors
|
||||
* {@link LogErrorEmailFormatter} is such an example that formats errors
|
||||
* into HTML for human readability in an email client.
|
||||
*
|
||||
* Formatters are added to writers like this:
|
||||
* <code>
|
||||
* $logEmailWriter = new SS_LogEmailWriter('my@email.com');
|
||||
* $logEmailWriter = new LogEmailWriter('my@email.com');
|
||||
* $myEmailFormatter = new MyLogEmailFormatter();
|
||||
* $logEmailWriter->setFormatter($myEmailFormatter);
|
||||
* </code>
|
||||
*/
|
||||
class SS_Log
|
||||
class Log
|
||||
{
|
||||
|
||||
const ERR = 'error';
|
||||
@ -77,7 +77,7 @@ class SS_Log
|
||||
* error code, error line, error context (backtrace).
|
||||
*
|
||||
* @param mixed $message Exception object or array of error context variables
|
||||
* @param string $priority Priority. Possible values: SS_Log::ERR, SS_Log::WARN, SS_Log::NOTICE, SS_Log::INFO or SS_Log::DEBUG
|
||||
* @param string $priority Priority. Possible values: Log::ERR, Log::WARN, Log::NOTICE, Log::INFO or Log::DEBUG
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Use Injector::inst()->get('Logger')->log($priority, $message) instead
|
||||
*/
|
@ -23,7 +23,7 @@ use LogicException;
|
||||
* - filter
|
||||
* - exclude
|
||||
*/
|
||||
class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sortable, SS_Limitable {
|
||||
class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, Limitable {
|
||||
|
||||
/**
|
||||
* Holds the items in the list
|
||||
@ -290,11 +290,11 @@ class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sorta
|
||||
*
|
||||
* @param string $keyfield The 'key' field of the result array
|
||||
* @param string $titlefield The value field of the result array
|
||||
* @return SS_Map
|
||||
* @return Map
|
||||
*/
|
||||
public function map($keyfield = 'ID', $titlefield = 'Title') {
|
||||
$list = clone $this;
|
||||
return new SS_Map($list, $keyfield, $titlefield);
|
||||
return new Map($list, $keyfield, $titlefield);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -617,7 +617,7 @@ class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sorta
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SS_Filterable::filterByCallback()
|
||||
* @see Filterable::filterByCallback()
|
||||
*
|
||||
* @example $list = $list->filterByCallback(function($item, $list) { return $item->Age == 9; })
|
||||
* @param callable $callback
|
||||
|
@ -38,7 +38,7 @@ abstract class DBConnector {
|
||||
* @param integer $errorLevel The level of the error to throw.
|
||||
* @param string $sql The SQL related to this query
|
||||
* @param array $parameters Parameters passed to the query
|
||||
* @throws SS_DatabaseException
|
||||
* @throws DatabaseException
|
||||
*/
|
||||
protected function databaseError($msg, $errorLevel = E_USER_ERROR, $sql = null, $parameters = array()) {
|
||||
// Prevent errors when error checking is set at zero level
|
||||
@ -54,7 +54,7 @@ abstract class DBConnector {
|
||||
if($errorLevel === E_USER_ERROR) {
|
||||
// Treating errors as exceptions better allows for responding to errors
|
||||
// in code, such as credential checking during installation
|
||||
throw new SS_DatabaseException($msg, 0, null, $sql, $parameters);
|
||||
throw new DatabaseException($msg, 0, null, $sql, $parameters);
|
||||
} else {
|
||||
user_error($msg, $errorLevel);
|
||||
}
|
||||
@ -194,7 +194,7 @@ abstract class DBConnector {
|
||||
* @param string $sql The SQL query to execute. The ? character will denote parameters.
|
||||
* @param array $parameters An ordered list of arguments.
|
||||
* @param int $errorLevel The level of error reporting to enable for the query
|
||||
* @return SS_Query
|
||||
* @return Query
|
||||
*/
|
||||
abstract public function preparedQuery($sql, $parameters, $errorLevel = E_USER_ERROR);
|
||||
|
||||
|
@ -29,7 +29,7 @@ abstract class DBSchemaManager {
|
||||
/**
|
||||
* Instance of the database controller this schema belongs to
|
||||
*
|
||||
* @var SS_Database
|
||||
* @var Database
|
||||
*/
|
||||
protected $database = null;
|
||||
|
||||
@ -44,9 +44,9 @@ abstract class DBSchemaManager {
|
||||
/**
|
||||
* Injector injection point for database controller
|
||||
*
|
||||
* @param SS_Database $database
|
||||
* @param Database $database
|
||||
*/
|
||||
public function setDatabase(SS_Database $database) {
|
||||
public function setDatabase(Database $database) {
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ abstract class DBSchemaManager {
|
||||
*
|
||||
* @param string $sql The SQL query to execute
|
||||
* @param int $errorLevel The level of error reporting to enable for the query
|
||||
* @return SS_Query
|
||||
* @return Query
|
||||
*/
|
||||
public function query($sql, $errorLevel = E_USER_ERROR) {
|
||||
return $this->database->query($sql, $errorLevel);
|
||||
@ -99,7 +99,7 @@ abstract class DBSchemaManager {
|
||||
* @param string $sql The SQL query to execute. The ? character will denote parameters.
|
||||
* @param array $parameters An ordered list of arguments.
|
||||
* @param int $errorLevel The level of error reporting to enable for the query
|
||||
* @return SS_Query
|
||||
* @return Query
|
||||
*/
|
||||
public function preparedQuery($sql, $parameters, $errorLevel = E_USER_ERROR) {
|
||||
return $this->database->preparedQuery($sql, $parameters, $errorLevel);
|
||||
|
@ -15,7 +15,7 @@ use Exception;
|
||||
* Abstract database connectivity class.
|
||||
* Sub-classes of this implement the actual database connection libraries
|
||||
*/
|
||||
abstract class SS_Database {
|
||||
abstract class Database {
|
||||
|
||||
/**
|
||||
* Database connector object
|
||||
@ -117,7 +117,7 @@ abstract class SS_Database {
|
||||
*
|
||||
* @param string $sql The SQL query to execute
|
||||
* @param int $errorLevel The level of error reporting to enable for the query
|
||||
* @return SS_Query
|
||||
* @return Query
|
||||
*/
|
||||
public function query($sql, $errorLevel = E_USER_ERROR) {
|
||||
// Check if we should only preview this query
|
||||
@ -142,7 +142,7 @@ abstract class SS_Database {
|
||||
* @param string $sql The SQL query to execute. The ? character will denote parameters.
|
||||
* @param array $parameters An ordered list of arguments.
|
||||
* @param int $errorLevel The level of error reporting to enable for the query
|
||||
* @return SS_Query
|
||||
* @return Query
|
||||
*/
|
||||
public function preparedQuery($sql, $parameters, $errorLevel = E_USER_ERROR) {
|
||||
// Check if we should only preview this query
|
@ -7,7 +7,7 @@ use Exception;
|
||||
/**
|
||||
* Error class for database exceptions
|
||||
*/
|
||||
class SS_DatabaseException extends Exception {
|
||||
class DatabaseException extends Exception {
|
||||
|
||||
/**
|
||||
* The SQL that generated this error
|
||||
|
@ -19,7 +19,7 @@ use Exception;
|
||||
* You are advised to backup your tables if changing settings on an existing database
|
||||
* `connection_charset` and `charset` should be equal, similarly so should `connection_collation` and `collation`
|
||||
*/
|
||||
class MySQLDatabase extends SS_Database {
|
||||
class MySQLDatabase extends Database {
|
||||
use Configurable;
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\ORM\Connect;
|
||||
/**
|
||||
* A result-set from a MySQL database (using MySQLiConnector)
|
||||
*/
|
||||
class MySQLQuery extends SS_Query {
|
||||
class MySQLQuery extends Query {
|
||||
|
||||
/**
|
||||
* The internal MySQL handle that points to the result set.
|
||||
|
@ -11,7 +11,7 @@ use mysqli_stmt;
|
||||
* By default streams unbuffered data, but seek(), rewind(), or numRecords() will force the statement to
|
||||
* buffer itself and sacrifice any potential performance benefit.
|
||||
*/
|
||||
class MySQLStatement extends SS_Query {
|
||||
class MySQLStatement extends Query {
|
||||
|
||||
/**
|
||||
* The related mysqli statement object if generated using a prepared query
|
||||
|
@ -8,7 +8,7 @@ use PDO;
|
||||
/**
|
||||
* A result-set from a PDO database.
|
||||
*/
|
||||
class PDOQuery extends SS_Query {
|
||||
class PDOQuery extends Query {
|
||||
/**
|
||||
* The internal MySQL handle that points to the result set.
|
||||
* @var PDOStatement
|
||||
|
@ -2,10 +2,8 @@
|
||||
|
||||
namespace SilverStripe\ORM\Connect;
|
||||
|
||||
use Iterator;
|
||||
|
||||
use SilverStripe\Core\Convert;
|
||||
|
||||
use Iterator;
|
||||
|
||||
/**
|
||||
* Abstract query-result class.
|
||||
@ -17,7 +15,7 @@ use SilverStripe\Core\Convert;
|
||||
* on providing the specific data-access methods that are required: {@link nextRecord()}, {@link numRecords()}
|
||||
* and {@link seek()}
|
||||
*/
|
||||
abstract class SS_Query implements Iterator {
|
||||
abstract class Query implements Iterator {
|
||||
|
||||
/**
|
||||
* The current record in the interator.
|
18
ORM/DB.php
18
ORM/DB.php
@ -9,9 +9,9 @@ use SilverStripe\Control\Cookie;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\ORM\Connect\DBConnector;
|
||||
use SilverStripe\ORM\Connect\DBSchemaManager;
|
||||
use SilverStripe\ORM\Connect\SS_Query;
|
||||
use SilverStripe\ORM\Connect\Query;
|
||||
use SilverStripe\ORM\Queries\SQLExpression;
|
||||
use SilverStripe\ORM\Connect\SS_Database;
|
||||
use SilverStripe\ORM\Connect\Database;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
|
||||
@ -32,7 +32,7 @@ class DB {
|
||||
|
||||
/**
|
||||
* The global database connection.
|
||||
* @var SS_Database
|
||||
* @var Database
|
||||
*/
|
||||
private static $connections = array();
|
||||
|
||||
@ -52,13 +52,13 @@ class DB {
|
||||
* Pass an object that's a subclass of SS_Database. This object will be used when {@link DB::query()}
|
||||
* is called.
|
||||
*
|
||||
* @param SS_Database $connection The connecton object to set as the connection.
|
||||
* @param Database $connection The connecton object to set as the connection.
|
||||
* @param string $name The name to give to this connection. If you omit this argument, the connection
|
||||
* will be the default one used by the ORM. However, you can store other named connections to
|
||||
* be accessed through DB::get_conn($name). This is useful when you have an application that
|
||||
* needs to connect to more than one database.
|
||||
*/
|
||||
public static function set_conn(SS_Database $connection, $name = 'default') {
|
||||
public static function set_conn(Database $connection, $name = 'default') {
|
||||
self::$connections[$name] = $connection;
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ class DB {
|
||||
*
|
||||
* @param string $name An optional name given to a connection in the DB::setConn() call. If omitted,
|
||||
* the default connection is returned.
|
||||
* @return SS_Database
|
||||
* @return Database
|
||||
*/
|
||||
public static function get_conn($name = 'default') {
|
||||
if(isset(self::$connections[$name])) {
|
||||
@ -234,7 +234,7 @@ class DB {
|
||||
* @param array $databaseConfig A map of options. The 'type' is the name of the
|
||||
* subclass of SS_Database to use. For the rest of the options, see the specific class.
|
||||
* @param string $label identifier for the connection
|
||||
* @return SS_Database
|
||||
* @return Database
|
||||
*/
|
||||
public static function connect($databaseConfig, $label = 'default') {
|
||||
|
||||
@ -274,7 +274,7 @@ class DB {
|
||||
* Execute the given SQL query.
|
||||
* @param string $sql The SQL query to execute
|
||||
* @param int $errorLevel The level of error reporting to enable for the query
|
||||
* @return SS_Query
|
||||
* @return Query
|
||||
*/
|
||||
public static function query($sql, $errorLevel = E_USER_ERROR) {
|
||||
self::$lastQuery = $sql;
|
||||
@ -309,7 +309,7 @@ class DB {
|
||||
* @param string $sql The SQL query to execute. The ? character will denote parameters.
|
||||
* @param array $parameters An ordered list of arguments.
|
||||
* @param int $errorLevel The level of error reporting to enable for the query
|
||||
* @return SS_Query
|
||||
* @return Query
|
||||
*/
|
||||
public static function prepared_query($sql, $parameters, $errorLevel = E_USER_ERROR) {
|
||||
self::$lastQuery = $sql;
|
||||
|
@ -32,7 +32,7 @@ use LogicException;
|
||||
*
|
||||
* Subclasses of DataList may add other methods that have the same effect.
|
||||
*/
|
||||
class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortable, SS_Limitable {
|
||||
class DataList extends ViewableData implements SS_List, Filterable, Sortable, Limitable {
|
||||
|
||||
/**
|
||||
* The DataObject class name that this data list is querying
|
||||
@ -460,7 +460,7 @@ class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortab
|
||||
/**
|
||||
* Note that, in the current implementation, the filtered list will be an ArrayList, but this may change in a
|
||||
* future implementation.
|
||||
* @see SS_Filterable::filterByCallback()
|
||||
* @see Filterable::filterByCallback()
|
||||
*
|
||||
* @example $list = $list->filterByCallback(function($item, $list) { return $item->Age == 9; })
|
||||
* @param callable $callback
|
||||
@ -724,10 +724,10 @@ class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortab
|
||||
*
|
||||
* @param string $keyField - the 'key' field of the result array
|
||||
* @param string $titleField - the value field of the result array
|
||||
* @return SS_Map
|
||||
* @return Map
|
||||
*/
|
||||
public function map($keyField = 'ID', $titleField = 'Title') {
|
||||
return new SS_Map($this, $keyField, $titleField);
|
||||
return new Map($this, $keyField, $titleField);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@ use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\Connect\SS_Query;
|
||||
use SilverStripe\ORM\Connect\Query;
|
||||
use SilverStripe\ORM\Queries\SQLConditionGroup;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use InvalidArgumentException;
|
||||
@ -384,7 +384,7 @@ class DataQuery {
|
||||
/**
|
||||
* Execute the query and return the result as {@link SS_Query} object.
|
||||
*
|
||||
* @return SS_Query
|
||||
* @return Query
|
||||
*/
|
||||
public function execute() {
|
||||
return $this->getFinalisedQuery()->execute();
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\ORM;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
@ -117,7 +117,7 @@ class DatabaseAdmin extends Controller {
|
||||
increase_time_limit_to(600);
|
||||
|
||||
// Get all our classes
|
||||
SS_ClassLoader::instance()->getManifest()->regenerate();
|
||||
ClassLoader::instance()->getManifest()->regenerate();
|
||||
|
||||
$url = $this->getReturnURL();
|
||||
if($url) {
|
||||
|
@ -8,9 +8,9 @@ namespace SilverStripe\ORM;
|
||||
* All methods in this interface are immutable - they should return new instances with the filter
|
||||
* applied, rather than applying the filter in place
|
||||
*
|
||||
* @see SS_List, SS_Sortable, SS_Limitable
|
||||
* @see SS_List, Sortable, Limitable
|
||||
*/
|
||||
interface SS_Filterable extends SS_List {
|
||||
interface Filterable extends SS_List {
|
||||
|
||||
/**
|
||||
* Returns TRUE if the list can be filtered by a given field expression.
|
||||
@ -23,7 +23,7 @@ interface SS_Filterable extends SS_List {
|
||||
/**
|
||||
* Return a new instance of this list that only includes items with these charactaristics
|
||||
*
|
||||
* @return SS_Filterable
|
||||
* @return Filterable
|
||||
* @example $list = $list->filter('Name', 'bob'); // only bob in the list
|
||||
* @example $list = $list->filter('Name', array('aziz', 'bob'); // aziz and bob in list
|
||||
* @example $list = $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the age 21
|
||||
@ -60,7 +60,7 @@ interface SS_Filterable extends SS_List {
|
||||
/**
|
||||
* Return a new instance of this list that excludes any items with these charactaristics
|
||||
*
|
||||
* @return SS_Filterable
|
||||
* @return Filterable
|
||||
* @example $list = $list->exclude('Name', 'bob'); // exclude bob from list
|
||||
* @example $list = $list->exclude('Name', array('aziz', 'bob'); // exclude aziz and bob from list
|
||||
* @example $list = $list->exclude(array('Name'=>'bob, 'Age'=>21)); // exclude bob that has Age 21
|
||||
@ -77,7 +77,7 @@ interface SS_Filterable extends SS_List {
|
||||
*
|
||||
* @example $list = $list->filterByCallback(function($item, $list) { return $item->Age == 9; })
|
||||
* @param callable $callback
|
||||
* @return SS_Filterable
|
||||
* @return Filterable
|
||||
*/
|
||||
public function filterByCallback($callback);
|
||||
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\View\ArrayData;
|
||||
* A list decorator that allows a list to be grouped into sub-lists by common
|
||||
* values of a field.
|
||||
*/
|
||||
class GroupedList extends SS_ListDecorator {
|
||||
class GroupedList extends ListDecorator {
|
||||
|
||||
/**
|
||||
* @param string $index
|
||||
|
@ -8,9 +8,9 @@ namespace SilverStripe\ORM;
|
||||
* All methods in this interface are immutable - they should return new instances with the limit
|
||||
* applied, rather than applying the limit in place
|
||||
*
|
||||
* @see SS_List, SS_Sortable, SS_Filterable
|
||||
* @see SS_List, Sortable, Filterable
|
||||
*/
|
||||
interface SS_Limitable extends SS_List {
|
||||
interface Limitable extends SS_List {
|
||||
|
||||
/**
|
||||
* Returns a new instance of this list where no more than $limit records are included.
|
||||
|
@ -60,7 +60,7 @@ interface SS_List extends ArrayAccess, Countable, IteratorAggregate {
|
||||
*
|
||||
* @param string $keyfield
|
||||
* @param string $titlefield
|
||||
* @return SS_Map
|
||||
* @return Map
|
||||
*/
|
||||
public function map($keyfield = 'ID', $titlefield = 'Title');
|
||||
|
||||
|
@ -10,7 +10,7 @@ use LogicException;
|
||||
* functionality. It passes through list methods to the underlying list
|
||||
* implementation.
|
||||
*/
|
||||
abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Sortable, SS_Filterable, SS_Limitable {
|
||||
abstract class ListDecorator extends ViewableData implements SS_List, Sortable, Filterable, Limitable {
|
||||
|
||||
/**
|
||||
* @var SS_List
|
||||
@ -179,7 +179,7 @@ abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Sort
|
||||
/**
|
||||
* Note that, in the current implementation, the filtered list will be an ArrayList, but this may change in a
|
||||
* future implementation.
|
||||
* @see SS_Filterable::filterByCallback()
|
||||
* @see Filterable::filterByCallback()
|
||||
*
|
||||
* @example $list = $list->filterByCallback(function($item, $list) { return $item->Age == 9; })
|
||||
* @param callable $callback
|
||||
|
@ -9,19 +9,19 @@ use IteratorAggregate;
|
||||
/**
|
||||
* Creates a map from an SS_List by defining a key column and a value column.
|
||||
*/
|
||||
class SS_Map implements ArrayAccess, Countable, IteratorAggregate {
|
||||
class Map implements ArrayAccess, Countable, IteratorAggregate {
|
||||
|
||||
protected $list, $keyField, $valueField;
|
||||
|
||||
/**
|
||||
* @see SS_Map::unshift()
|
||||
* @see Map::unshift()
|
||||
*
|
||||
* @var array $firstItems
|
||||
*/
|
||||
protected $firstItems = array();
|
||||
|
||||
/**
|
||||
* @see SS_Map::push()
|
||||
* @see Map::push()
|
||||
*
|
||||
* @var array $lastItems
|
||||
*/
|
||||
@ -182,10 +182,10 @@ class SS_Map implements ArrayAccess, Countable, IteratorAggregate {
|
||||
|
||||
/**
|
||||
* Sets a value in the map by a given key that has been set via
|
||||
* {@link SS_Map::push()} or {@link SS_Map::unshift()}
|
||||
* {@link Map::push()} or {@link Map::unshift()}
|
||||
*
|
||||
* Keys in the map cannot be set since these values are derived from a
|
||||
* {@link DataQuery} instance. In this case, use {@link SS_Map::toArray()}
|
||||
* {@link DataQuery} instance. In this case, use {@link Map::toArray()}
|
||||
* and manipulate the resulting array.
|
||||
*
|
||||
* @var string $key
|
||||
@ -201,17 +201,17 @@ class SS_Map implements ArrayAccess, Countable, IteratorAggregate {
|
||||
}
|
||||
|
||||
user_error(
|
||||
'SS_Map is read-only. Please use $map->push($key, $value) to append values',
|
||||
'Map is read-only. Please use $map->push($key, $value) to append values',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a value in the map by a given key which has been added to the map
|
||||
* via {@link SS_Map::push()} or {@link SS_Map::unshift()}
|
||||
* via {@link Map::push()} or {@link Map::unshift()}
|
||||
*
|
||||
* Keys in the map cannot be unset since these values are derived from a
|
||||
* {@link DataQuery} instance. In this case, use {@link SS_Map::toArray()}
|
||||
* {@link DataQuery} instance. In this case, use {@link Map::toArray()}
|
||||
* and manipulate the resulting array.
|
||||
*
|
||||
* @var string $key
|
||||
@ -231,21 +231,21 @@ class SS_Map implements ArrayAccess, Countable, IteratorAggregate {
|
||||
}
|
||||
|
||||
user_error(
|
||||
"SS_Map is read-only. Unset cannot be called on keys derived from the DataQuery",
|
||||
"Map is read-only. Unset cannot be called on keys derived from the DataQuery",
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an SS_Map_Iterator instance for iterating over the complete set
|
||||
* Returns an Map_Iterator instance for iterating over the complete set
|
||||
* of items in the map.
|
||||
*
|
||||
* Satisfies the IteratorAggreagte interface.
|
||||
*
|
||||
* @return SS_Map_Iterator
|
||||
* @return Map_Iterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
return new SS_Map_Iterator(
|
||||
return new Map_Iterator(
|
||||
$this->list->getIterator(),
|
||||
$this->keyField,
|
||||
$this->valueField,
|
||||
@ -256,7 +256,7 @@ class SS_Map implements ArrayAccess, Countable, IteratorAggregate {
|
||||
|
||||
/**
|
||||
* Returns the count of items in the list including the additional items set
|
||||
* through {@link SS_Map::push()} and {@link SS_Map::unshift}.
|
||||
* through {@link Map::push()} and {@link Map::unshift}.
|
||||
*
|
||||
* @return int
|
||||
*/
|
@ -5,9 +5,9 @@ namespace SilverStripe\ORM;
|
||||
use Iterator;
|
||||
|
||||
/**
|
||||
* Builds a map iterator around an Iterator. Called by SS_Map
|
||||
* Builds a map iterator around an Iterator. Called by Map
|
||||
*/
|
||||
class SS_Map_Iterator implements Iterator
|
||||
class Map_Iterator implements Iterator
|
||||
{
|
||||
|
||||
/**
|
@ -12,7 +12,7 @@ use IteratorIterator;
|
||||
/**
|
||||
* A decorator that wraps around a data list in order to provide pagination.
|
||||
*/
|
||||
class PaginatedList extends SS_ListDecorator
|
||||
class PaginatedList extends ListDecorator
|
||||
{
|
||||
|
||||
protected $request;
|
||||
@ -486,7 +486,7 @@ class PaginatedList extends SS_ListDecorator
|
||||
/**
|
||||
* Set the request object for this list
|
||||
*
|
||||
* @param SS_HTTPRequest
|
||||
* @param HTTPRequest
|
||||
*/
|
||||
public function setRequest($request)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\ORM\Queries;
|
||||
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\Connect\SS_Query;
|
||||
use SilverStripe\ORM\Connect\Query;
|
||||
use SilverStripe\ORM\DB;
|
||||
use Exception;
|
||||
|
||||
@ -100,7 +100,7 @@ abstract class SQLExpression {
|
||||
/**
|
||||
* Execute this query.
|
||||
*
|
||||
* @return SS_Query
|
||||
* @return Query
|
||||
*/
|
||||
public function execute() {
|
||||
$sql = $this->sql($parameters);
|
||||
|
@ -7,7 +7,7 @@ use SilverStripe\ORM\FieldType\DBField;
|
||||
/**
|
||||
* Abstract representation of a DB relation field, either saved or in memory
|
||||
*/
|
||||
interface Relation extends SS_List, SS_Filterable, SS_Sortable, SS_Limitable {
|
||||
interface Relation extends SS_List, Filterable, Sortable, Limitable {
|
||||
|
||||
/**
|
||||
* Sets the ComponentSet to be the given ID list.
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\ORM\Search;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
@ -156,7 +156,7 @@ class SearchContext extends Object {
|
||||
$query = $query->sort($sort);
|
||||
|
||||
// hack to work with $searchParems when it's an Object
|
||||
if ($searchParams instanceof SS_HTTPRequest) {
|
||||
if ($searchParams instanceof HTTPRequest) {
|
||||
$searchParamArray = $searchParams->getVars();
|
||||
} else {
|
||||
$searchParamArray = $searchParams;
|
||||
|
@ -8,9 +8,9 @@ namespace SilverStripe\ORM;
|
||||
* All methods in this interface are immutable - they should return new instances with the sort
|
||||
* applied, rather than applying the sort in place
|
||||
*
|
||||
* @see SS_List, SS_Filterable, SS_Limitable
|
||||
* @see SS_List, Filterable, Limitable
|
||||
*/
|
||||
interface SS_Sortable extends SS_List {
|
||||
interface Sortable extends SS_List {
|
||||
|
||||
/**
|
||||
* Returns TRUE if the list can be sorted by a field.
|
||||
@ -36,7 +36,7 @@ interface SS_Sortable extends SS_List {
|
||||
/**
|
||||
* Return a new instance of this list based on reversing the current sort.
|
||||
*
|
||||
* @return SS_Sortable
|
||||
* @return Sortable
|
||||
* @example $list = $list->reverse();
|
||||
*/
|
||||
public function reverse();
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\ORM\Versioning;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\Cookie;
|
||||
@ -1918,7 +1918,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
||||
/**
|
||||
* Determine if the current user is able to set the given site stage / archive
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public static function can_choose_site_stage($request) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\ORM\Versioning;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\FormAction;
|
||||
@ -86,7 +86,7 @@ class VersionedGridFieldItemRequest extends GridFieldDetailForm_ItemRequest {
|
||||
*
|
||||
* @param array $data
|
||||
* @param Form $form
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function doArchive($data, $form) {
|
||||
/** @var Versioned|DataObject $record */
|
||||
@ -123,7 +123,7 @@ class VersionedGridFieldItemRequest extends GridFieldDetailForm_ItemRequest {
|
||||
*
|
||||
* @param array $data
|
||||
* @param Form $form
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function doPublish($data, $form) {
|
||||
/** @var Versioned|DataObject $record */
|
||||
@ -166,7 +166,7 @@ class VersionedGridFieldItemRequest extends GridFieldDetailForm_ItemRequest {
|
||||
*
|
||||
* @param array $data
|
||||
* @param Form $form
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function doUnpublish($data, $form) {
|
||||
/** @var Versioned|DataObject $record */
|
||||
|
@ -3,8 +3,8 @@
|
||||
namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
@ -47,7 +47,7 @@ class BasicAuth {
|
||||
*
|
||||
* Used by {@link Controller::init()}.
|
||||
*
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @throws HTTPResponse_Exception
|
||||
*
|
||||
* @param string $realm
|
||||
* @param string|array $permissionCode Optional
|
||||
@ -90,7 +90,7 @@ class BasicAuth {
|
||||
|
||||
// If we've failed the authentication mechanism, then show the login form
|
||||
if(!$member) {
|
||||
$response = new SS_HTTPResponse(null, 401);
|
||||
$response = new HTTPResponse(null, 401);
|
||||
$response->addHeader('WWW-Authenticate', "Basic realm=\"$realm\"");
|
||||
|
||||
if(isset($_SERVER['PHP_AUTH_USER'])) {
|
||||
@ -100,13 +100,13 @@ class BasicAuth {
|
||||
}
|
||||
|
||||
// Exception is caught by RequestHandler->handleRequest() and will halt further execution
|
||||
$e = new SS_HTTPResponse_Exception(null, 401);
|
||||
$e = new HTTPResponse_Exception(null, 401);
|
||||
$e->setResponse($response);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if($permissionCode && !Permission::checkMember($member->ID, $permissionCode)) {
|
||||
$response = new SS_HTTPResponse(null, 401);
|
||||
$response = new HTTPResponse(null, 401);
|
||||
$response->addHeader('WWW-Authenticate', "Basic realm=\"$realm\"");
|
||||
|
||||
if(isset($_SERVER['PHP_AUTH_USER'])) {
|
||||
@ -114,7 +114,7 @@ class BasicAuth {
|
||||
}
|
||||
|
||||
// Exception is caught by RequestHandler->handleRequest() and will halt further execution
|
||||
$e = new SS_HTTPResponse_Exception(null, 401);
|
||||
$e = new HTTPResponse_Exception(null, 401);
|
||||
$e->setResponse($response);
|
||||
throw $e;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Session;
|
||||
@ -101,7 +101,7 @@ class CMSMemberLoginForm extends LoginForm {
|
||||
* This method is called when the user clicks on "Log in"
|
||||
*
|
||||
* @param array $data Submitted data
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function dologin($data) {
|
||||
if($this->performLogin($data)) {
|
||||
@ -119,7 +119,7 @@ class CMSMemberLoginForm extends LoginForm {
|
||||
/**
|
||||
* Redirect the user to the change password form.
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
protected function redirectToChangePassword() {
|
||||
// Since this form is loaded via an iframe, this redirect must be performed via javascript
|
||||
@ -163,7 +163,7 @@ PHP
|
||||
* Send user to the right location after login
|
||||
*
|
||||
* @param array $data
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
protected function logInUserAndRedirect($data) {
|
||||
// Check password expiry
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\Admin\AdminRootController;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\Controller;
|
||||
@ -108,7 +108,7 @@ class CMSSecurity extends Security {
|
||||
/**
|
||||
* Redirects the user to the external login page
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
protected function redirectToExternalLogin() {
|
||||
$loginURL = Security::create()->Link('login');
|
||||
@ -186,7 +186,7 @@ PHP
|
||||
/**
|
||||
* Given a successful login, tell the parent frame to close the dialog
|
||||
*
|
||||
* @return SS_HTTPResponse|DBField
|
||||
* @return HTTPResponse|DBField
|
||||
*/
|
||||
public function success() {
|
||||
// Ensure member is properly logged in
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\Director;
|
||||
@ -67,7 +67,7 @@ class ChangePasswordForm extends Form {
|
||||
* Change the password
|
||||
*
|
||||
* @param array $data The user submitted data
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function doChangePassword(array $data) {
|
||||
if($member = Member::currentUser()) {
|
||||
|
@ -28,7 +28,7 @@ use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\HasManyList;
|
||||
use SilverStripe\ORM\ManyManyList;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\SS_Map;
|
||||
use SilverStripe\ORM\Map;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\View\SSViewer;
|
||||
@ -1261,7 +1261,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
||||
* If no $groups is passed, all members will be returned
|
||||
*
|
||||
* @param mixed $groups - takes a SS_List, an array or a single Group.ID
|
||||
* @return SS_Map Returns an SS_Map that returns all Member data.
|
||||
* @return Map Returns an Map that returns all Member data.
|
||||
*/
|
||||
public static function map_in_groups($groups = null) {
|
||||
$groupIDList = array();
|
||||
@ -1299,7 +1299,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
||||
*
|
||||
* @param array $groups Groups to consider or NULL to use all groups with
|
||||
* CMS permissions.
|
||||
* @return SS_Map Returns a map of all members in the groups given that
|
||||
* @return Map Returns a map of all members in the groups given that
|
||||
* have CMS permissions.
|
||||
*/
|
||||
public static function mapInCMSGroups($groups = null) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\Session;
|
||||
@ -219,7 +219,7 @@ JS;
|
||||
* )
|
||||
*
|
||||
* @param array $data
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
protected function logInUserAndRedirect($data) {
|
||||
Session::clear('SessionForms.MemberLoginForm.Email');
|
||||
@ -319,7 +319,7 @@ JS;
|
||||
*
|
||||
* @skipUpgrade
|
||||
* @param array $data Submitted data
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function forgotPassword($data) {
|
||||
// Ensure password is given
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
|
||||
/**
|
||||
@ -22,7 +22,7 @@ class NullSecurityToken extends SecurityToken
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return Boolean
|
||||
*/
|
||||
public function checkRequest($request)
|
||||
|
@ -4,8 +4,8 @@ namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Convert;
|
||||
@ -252,7 +252,7 @@ class Security extends Controller implements TemplateGlobalProvider {
|
||||
*
|
||||
* The alreadyLoggedIn value can contain a '%s' placeholder that will be replaced with a link
|
||||
* to log in.
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public static function permissionFailure($controller = null, $messageSet = null) {
|
||||
self::set_ignore_disallowed_actions(true);
|
||||
@ -260,7 +260,7 @@ class Security extends Controller implements TemplateGlobalProvider {
|
||||
if(!$controller) $controller = Controller::curr();
|
||||
|
||||
if(Director::is_ajax()) {
|
||||
$response = ($controller) ? $controller->getResponse() : new SS_HTTPResponse();
|
||||
$response = ($controller) ? $controller->getResponse() : new HTTPResponse();
|
||||
$response->setStatusCode(403);
|
||||
if(!Member::currentUser()) {
|
||||
$response->setBody(_t('ContentController.NOTLOGGEDIN','Not logged in'));
|
||||
@ -303,7 +303,7 @@ class Security extends Controller implements TemplateGlobalProvider {
|
||||
|
||||
// Work out the right message to show
|
||||
if($member && $member->exists()) {
|
||||
$response = ($controller) ? $controller->getResponse() : new SS_HTTPResponse();
|
||||
$response = ($controller) ? $controller->getResponse() : new HTTPResponse();
|
||||
$response->setStatusCode(403);
|
||||
|
||||
//If 'alreadyLoggedIn' is not specified in the array, then use the default
|
||||
@ -320,7 +320,7 @@ class Security extends Controller implements TemplateGlobalProvider {
|
||||
$form->sessionMessage($message, 'warning');
|
||||
Session::set('MemberLoginForm.force_message',1);
|
||||
$loginResponse = $me->login();
|
||||
if($loginResponse instanceof SS_HTTPResponse) {
|
||||
if($loginResponse instanceof HTTPResponse) {
|
||||
return $loginResponse;
|
||||
}
|
||||
|
||||
@ -446,7 +446,7 @@ class Security extends Controller implements TemplateGlobalProvider {
|
||||
/**
|
||||
* Perform pre-login checking and prepare a response if available prior to login
|
||||
*
|
||||
* @return SS_HTTPResponse Substitute response object if the login process should be curcumvented.
|
||||
* @return HTTPResponse Substitute response object if the login process should be curcumvented.
|
||||
* Returns null if should proceed as normal.
|
||||
*/
|
||||
protected function preLogin() {
|
||||
@ -454,10 +454,10 @@ class Security extends Controller implements TemplateGlobalProvider {
|
||||
$eventResults = $this->extend('onBeforeSecurityLogin');
|
||||
// If there was a redirection, return
|
||||
if($this->redirectedTo()) return $this->getResponse();
|
||||
// If there was an SS_HTTPResponse object returned, then return that
|
||||
// If there was an HTTPResponse object returned, then return that
|
||||
if($eventResults) {
|
||||
foreach($eventResults as $result) {
|
||||
if($result instanceof SS_HTTPResponse) return $result;
|
||||
if($result instanceof HTTPResponse) return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -544,7 +544,7 @@ class Security extends Controller implements TemplateGlobalProvider {
|
||||
* For multiple authenticators, Security_MultiAuthenticatorLogin is used.
|
||||
* See getTemplatesFor and getIncludeTemplate for how to override template logic
|
||||
*
|
||||
* @return string|SS_HTTPResponse Returns the "login" page as HTML code.
|
||||
* @return string|HTTPResponse Returns the "login" page as HTML code.
|
||||
*/
|
||||
public function login() {
|
||||
// Check pre-login process
|
||||
@ -651,7 +651,7 @@ class Security extends Controller implements TemplateGlobalProvider {
|
||||
* Show the "password sent" page, after a user has requested
|
||||
* to reset their password.
|
||||
*
|
||||
* @param SS_HTTPRequest $request The SS_HTTPRequest for this action.
|
||||
* @param HTTPRequest $request The HTTPRequest for this action.
|
||||
* @return string Returns the "password sent" page as HTML code.
|
||||
*/
|
||||
public function passwordsent($request) {
|
||||
@ -709,7 +709,7 @@ class Security extends Controller implements TemplateGlobalProvider {
|
||||
*
|
||||
* @see ChangePasswordForm
|
||||
*
|
||||
* @return string|SS_HTTPRequest Returns the "change password" page as HTML code, or a redirect response
|
||||
* @return string|HTTPRequest Returns the "change password" page as HTML code, or a redirect response
|
||||
*/
|
||||
public function changepassword() {
|
||||
$controller = $this->getResponseController(_t('Security.CHANGEPASSWORDHEADER', 'Change your password'));
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\Controller;
|
||||
@ -179,7 +179,7 @@ class SecurityToken extends Object implements TemplateGlobalProvider {
|
||||
/**
|
||||
* See {@link check()}.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public function checkRequest($request) {
|
||||
@ -190,7 +190,7 @@ class SecurityToken extends Object implements TemplateGlobalProvider {
|
||||
/**
|
||||
* Get security token from request
|
||||
*
|
||||
* @param SS_HTTPREquest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return string
|
||||
*/
|
||||
protected function getRequestToken($request) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\View\Parsers;
|
||||
|
||||
class SS_HTML4Value extends SS_HTMLValue
|
||||
class HTML4Value extends HTMLValue
|
||||
{
|
||||
|
||||
/**
|
@ -15,7 +15,7 @@ use DOMDocument;
|
||||
* It's designed to allow dependancy injection to replace the standard HTML4 version with one that
|
||||
* handles XHTML or HTML5 instead
|
||||
*/
|
||||
abstract class SS_HTMLValue extends ViewableData {
|
||||
abstract class HTMLValue extends ViewableData {
|
||||
|
||||
public function __construct($fragment = null) {
|
||||
if ($fragment) $this->setContent($fragment);
|
@ -417,7 +417,7 @@ class ShortcodeParser extends Object {
|
||||
* We don't use markers with attributes because there's no point, it's easier to do all the matching
|
||||
* in-DOM after the XML parse
|
||||
*
|
||||
* @param SS_HTMLValue $htmlvalue
|
||||
* @param HTMLValue $htmlvalue
|
||||
*/
|
||||
protected function replaceAttributeTagsWithContent($htmlvalue) {
|
||||
$attributes = $htmlvalue->query('//@*[contains(.,"[")][contains(.,"]")]');
|
||||
@ -570,7 +570,7 @@ class ShortcodeParser extends Object {
|
||||
$content = $this->getShortcodeReplacementText($tag);
|
||||
|
||||
if ($content) {
|
||||
/** @var SS_HTMLValue $parsed */
|
||||
/** @var HTMLValue $parsed */
|
||||
$parsed = Injector::inst()->create('HTMLValue', $content);
|
||||
$body = $parsed->getBody();
|
||||
if ($body) $this->insertListAfter($body->childNodes, $node);
|
||||
@ -599,7 +599,7 @@ class ShortcodeParser extends Object {
|
||||
// use a proper DOM
|
||||
list($content, $tags) = $this->replaceElementTagsWithMarkers($content);
|
||||
|
||||
/** @var SS_HTMLValue $htmlvalue */
|
||||
/** @var HTMLValue $htmlvalue */
|
||||
$htmlvalue = Injector::inst()->create('HTMLValue', $content);
|
||||
|
||||
// Now parse the result into a DOM
|
||||
|
@ -10,11 +10,11 @@ use SilverStripe\Core\Object;
|
||||
* Usage:
|
||||
*
|
||||
* <code>
|
||||
* $tr = new SS_Transliterator();
|
||||
* $tr = new Transliterator();
|
||||
* $ascii = $tr->toASCII($unicode);
|
||||
* </code>
|
||||
*/
|
||||
class SS_Transliterator extends Object {
|
||||
class Transliterator extends Object {
|
||||
/**
|
||||
* @config
|
||||
* @var boolean Allow the use of iconv() to perform transliteration. Set to false to disable.
|
@ -6,7 +6,7 @@ use SilverStripe\Core\Object;
|
||||
|
||||
/**
|
||||
* Filter certain characters from "URL segments" (also called "slugs"), for nicer (more SEO-friendly) URLs.
|
||||
* Uses {@link SS_Transliterator} to convert non-ASCII characters to meaningful ASCII representations.
|
||||
* Uses {@link Transliterator} to convert non-ASCII characters to meaningful ASCII representations.
|
||||
* Use {@link $default_allow_multibyte} to allow a broader range of characters without transliteration.
|
||||
*
|
||||
* Caution: Should not be used on full URIs with domains or query parameters.
|
||||
@ -101,22 +101,22 @@ class URLSegmentFilter extends Object {
|
||||
}
|
||||
|
||||
/**
|
||||
* @var SS_Transliterator
|
||||
* @var Transliterator
|
||||
*/
|
||||
protected $transliterator;
|
||||
|
||||
/**
|
||||
* @return SS_Transliterator|NULL
|
||||
* @return Transliterator
|
||||
*/
|
||||
public function getTransliterator() {
|
||||
if($this->transliterator === null && $this->config()->default_use_transliterator) {
|
||||
$this->transliterator = SS_Transliterator::create();
|
||||
$this->transliterator = Transliterator::create();
|
||||
}
|
||||
return $this->transliterator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_Transliterator|FALSE
|
||||
* @param Transliterator $t
|
||||
*/
|
||||
public function setTransliterator($t) {
|
||||
$this->transliterator = $t;
|
||||
|
@ -6,7 +6,7 @@ use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Flushable;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
@ -292,9 +292,9 @@ class Requirements implements Flushable {
|
||||
* Attach requirements inclusion to X-Include-JS and X-Include-CSS headers on the given
|
||||
* HTTP Response
|
||||
*
|
||||
* @param SS_HTTPResponse $response
|
||||
* @param HTTPResponse $response
|
||||
*/
|
||||
public static function include_in_response(SS_HTTPResponse $response) {
|
||||
public static function include_in_response(HTTPResponse $response) {
|
||||
self::backend()->includeInResponse($response);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ use InvalidArgumentException;
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Assets\Storage\GeneratedAssetHandler;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
@ -890,9 +890,9 @@ class Requirements_Backend
|
||||
* Attach requirements inclusion to X-Include-JS and X-Include-CSS headers on the given
|
||||
* HTTP Response
|
||||
*
|
||||
* @param SS_HTTPResponse $response
|
||||
* @param HTTPResponse $response
|
||||
*/
|
||||
public function includeInResponse(SS_HTTPResponse $response)
|
||||
public function includeInResponse(HTTPResponse $response)
|
||||
{
|
||||
$this->processCombinedFiles();
|
||||
$jsRequirements = array();
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\View;
|
||||
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\SS_Cache;
|
||||
use SilverStripe\Core\Cache;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Flushable;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
@ -34,7 +34,7 @@ use Zend_Cache_Core;
|
||||
*
|
||||
* <b>Caching</b>
|
||||
*
|
||||
* Compiled templates are cached via {@link SS_Cache}, usually on the filesystem.
|
||||
* Compiled templates are cached via {@link Cache}, usually on the filesystem.
|
||||
* If you put ?flush=1 on your URL, it will force the template to be recompiled.
|
||||
*
|
||||
* @see http://doc.silverstripe.org/themes
|
||||
@ -442,7 +442,7 @@ class SSViewer implements Flushable {
|
||||
*/
|
||||
public static function flush_cacheblock_cache($force = false) {
|
||||
if (!self::$cacheblock_cache_flushed || $force) {
|
||||
$cache = SS_Cache::factory('cacheblock');
|
||||
$cache = Cache::factory('cacheblock');
|
||||
$backend = $cache->getBackend();
|
||||
|
||||
if(
|
||||
@ -480,7 +480,7 @@ class SSViewer implements Flushable {
|
||||
* @return Zend_Cache_Core
|
||||
*/
|
||||
public function getPartialCacheStore() {
|
||||
return $this->partialCacheStore ? $this->partialCacheStore : SS_Cache::factory('cacheblock');
|
||||
return $this->partialCacheStore ? $this->partialCacheStore : Cache::factory('cacheblock');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -528,7 +528,7 @@ class SSViewer implements Flushable {
|
||||
/**
|
||||
* The process() method handles the "meat" of the template processing.
|
||||
*
|
||||
* It takes care of caching the output (via {@link SS_Cache}), as well as
|
||||
* It takes care of caching the output (via {@link Cache}), as well as
|
||||
* replacing the special "$Content" and "$Layout" placeholders with their
|
||||
* respective subtemplates.
|
||||
*
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\SS_Cache;
|
||||
use SilverStripe\Core\Cache;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\View\Parsers\ShortcodeParser;
|
||||
|
||||
@ -36,7 +36,7 @@ ShortcodeParser::get('regenerator')
|
||||
$_ENV['TMPDIR'] = TEMP_FOLDER; // for *nix
|
||||
$_ENV['TMP'] = TEMP_FOLDER; // for Windows
|
||||
|
||||
SS_Cache::set_cache_lifetime('GDBackend_Manipulations', null, 100);
|
||||
Cache::set_cache_lifetime('GDBackend_Manipulations', null, 100);
|
||||
|
||||
// If you don't want to see deprecation errors for the new APIs, change this to 3.2.0-dev.
|
||||
Deprecation::notification_version('3.2.0');
|
||||
|
@ -3,6 +3,6 @@ Name: corehtml
|
||||
---
|
||||
SilverStripe\Core\Injector\Injector:
|
||||
HTMLValue:
|
||||
class: SilverStripe\View\Parsers\SS_HTML4Value
|
||||
class: SilverStripe\View\Parsers\HTML4Value
|
||||
SilverStripe\Forms\HTMLEditor\HTMLEditorConfig:
|
||||
class: SilverStripe\Forms\HTMLEditor\TinyMCEConfig
|
||||
|
@ -4,8 +4,8 @@ namespace SilverStripe\Admin;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\Core\Object;
|
||||
@ -85,7 +85,7 @@ class AddToCampaignHandler {
|
||||
/**
|
||||
* Perform the action. Either returns a Form or performs the action, as per the class doc
|
||||
*
|
||||
* @return DBHTMLText|SS_HTTPResponse
|
||||
* @return DBHTMLText|HTTPResponse
|
||||
*/
|
||||
public function handle() {
|
||||
$object = $this->getObject($this->data['ID'], $this->data['ClassName']);
|
||||
@ -118,7 +118,7 @@ class AddToCampaignHandler {
|
||||
* @param int $id The ID of the DataObject
|
||||
* @param string $class The Class of the DataObject
|
||||
* @return DataObject The referenced DataObject
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
protected function getObject($id, $class) {
|
||||
$id = (int)$id;
|
||||
@ -206,8 +206,8 @@ class AddToCampaignHandler {
|
||||
*
|
||||
* @param DataObject $object The object to add to the ChangeSet
|
||||
* @param int $campaignID The ID of the ChangeSet to add $object to
|
||||
* @return SS_HTTPResponse
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @return HTTPResponse
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public function addToCampaign($object, $campaignID) {
|
||||
/** @var ChangeSet $changeSet */
|
||||
@ -245,7 +245,7 @@ class AddToCampaignHandler {
|
||||
if ($request->getHeader('X-Formschema-Request')) {
|
||||
return $message;
|
||||
} elseif (Director::is_ajax()) {
|
||||
$response = new SS_HTTPResponse($message, 200);
|
||||
$response = new HTTPResponse($message, 200);
|
||||
|
||||
$response->addHeader('Content-Type', 'text/plain; charset=utf-8');
|
||||
return $response;
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Admin;
|
||||
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
@ -92,7 +92,7 @@ class AdminRootController extends Controller implements TemplateGlobalProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||
public function handleRequest(HTTPRequest $request, DataModel $model) {
|
||||
// If this is the final portion of the request (i.e. the URL is just /admin), direct to the default panel
|
||||
if ($request->allParsed()) {
|
||||
$segment = Config::inst()->get($this->config()->default_panel, 'url_segment');
|
||||
|
@ -3,8 +3,8 @@
|
||||
namespace SilverStripe\Admin;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
@ -102,8 +102,8 @@ class CMSBatchActionHandler extends RequestHandler {
|
||||
/**
|
||||
* Invoke a batch action
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function handleBatchAction($request) {
|
||||
// This method can't be called without ajax.
|
||||
@ -136,8 +136,8 @@ class CMSBatchActionHandler extends RequestHandler {
|
||||
/**
|
||||
* Respond with the list of applicable pages for a given filter
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function handleApplicablePages($request) {
|
||||
// Find the action handler
|
||||
@ -155,7 +155,7 @@ class CMSBatchActionHandler extends RequestHandler {
|
||||
$applicableIDs = array();
|
||||
}
|
||||
|
||||
$response = new SS_HTTPResponse(json_encode($applicableIDs));
|
||||
$response = new HTTPResponse(json_encode($applicableIDs));
|
||||
$response->addHeader("Content-type", "application/json");
|
||||
return $response;
|
||||
}
|
||||
@ -163,8 +163,8 @@ class CMSBatchActionHandler extends RequestHandler {
|
||||
/**
|
||||
* Check if this action has a confirmation step
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function handleConfirmation($request) {
|
||||
// Find the action handler
|
||||
@ -177,9 +177,9 @@ class CMSBatchActionHandler extends RequestHandler {
|
||||
|
||||
// Check dialog
|
||||
if($actionHandler->hasMethod('confirmationDialog')) {
|
||||
$response = new SS_HTTPResponse(json_encode($actionHandler->confirmationDialog($ids)));
|
||||
$response = new HTTPResponse(json_encode($actionHandler->confirmationDialog($ids)));
|
||||
} else {
|
||||
$response = new SS_HTTPResponse(json_encode(array('alert' => false)));
|
||||
$response = new HTTPResponse(json_encode(array('alert' => false)));
|
||||
}
|
||||
|
||||
$response->addHeader("Content-type", "application/json");
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Admin;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\Forms\FormAction;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
@ -24,7 +24,7 @@ class CMSProfileController extends LeftAndMain {
|
||||
|
||||
$form = parent::getEditForm($id, $fields);
|
||||
|
||||
if($form instanceof SS_HTTPResponse) {
|
||||
if($form instanceof HTTPResponse) {
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
namespace SilverStripe\Admin;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\Forms\FormAction;
|
||||
@ -211,10 +211,10 @@ JSON;
|
||||
/**
|
||||
* REST endpoint to get a list of campaigns.
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function readCampaigns() {
|
||||
$response = new SS_HTTPResponse();
|
||||
$response = new HTTPResponse();
|
||||
$response->addHeader('Content-Type', 'application/json');
|
||||
$hal = $this->getListResource();
|
||||
$response->setBody(Convert::array2json($hal));
|
||||
@ -368,31 +368,31 @@ JSON;
|
||||
/**
|
||||
* REST endpoint to get a campaign.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function readCampaign(SS_HTTPRequest $request) {
|
||||
$response = new SS_HTTPResponse();
|
||||
public function readCampaign(HTTPRequest $request) {
|
||||
$response = new HTTPResponse();
|
||||
|
||||
if ($request->getHeader('Accept') == 'text/json') {
|
||||
$response->addHeader('Content-Type', 'application/json');
|
||||
if (!$request->param('Name')) {
|
||||
return (new SS_HTTPResponse(null, 400));
|
||||
return (new HTTPResponse(null, 400));
|
||||
}
|
||||
|
||||
/** @var ChangeSet $changeSet */
|
||||
$changeSet = ChangeSet::get()->byID($request->param('ID'));
|
||||
if(!$changeSet) {
|
||||
return (new SS_HTTPResponse(null, 404));
|
||||
return (new HTTPResponse(null, 404));
|
||||
}
|
||||
|
||||
if(!$changeSet->canView()) {
|
||||
return (new SS_HTTPResponse(null, 403));
|
||||
return (new HTTPResponse(null, 403));
|
||||
}
|
||||
|
||||
$body = Convert::raw2json($this->getChangeSetResource($changeSet));
|
||||
return (new SS_HTTPResponse($body, 200))
|
||||
return (new HTTPResponse($body, 200))
|
||||
->addHeader('Content-Type', 'application/json');
|
||||
} else {
|
||||
return $this->index($request);
|
||||
@ -402,71 +402,71 @@ JSON;
|
||||
/**
|
||||
* REST endpoint to delete a campaign.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function deleteCampaign(SS_HTTPRequest $request) {
|
||||
public function deleteCampaign(HTTPRequest $request) {
|
||||
// Check security ID
|
||||
if (!SecurityToken::inst()->checkRequest($request)) {
|
||||
return new SS_HTTPResponse(null, 400);
|
||||
return new HTTPResponse(null, 400);
|
||||
}
|
||||
|
||||
$id = $request->param('ID');
|
||||
if (!$id || !is_numeric($id)) {
|
||||
return (new SS_HTTPResponse(null, 400));
|
||||
return (new HTTPResponse(null, 400));
|
||||
}
|
||||
|
||||
$record = ChangeSet::get()->byID($id);
|
||||
if(!$record) {
|
||||
return (new SS_HTTPResponse(null, 404));
|
||||
return (new HTTPResponse(null, 404));
|
||||
}
|
||||
|
||||
if(!$record->canDelete()) {
|
||||
return (new SS_HTTPResponse(null, 403));
|
||||
return (new HTTPResponse(null, 403));
|
||||
}
|
||||
|
||||
$record->delete();
|
||||
|
||||
return (new SS_HTTPResponse(null, 204));
|
||||
return (new HTTPResponse(null, 204));
|
||||
}
|
||||
|
||||
/**
|
||||
* REST endpoint to publish a {@link ChangeSet} and all of its items.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function publishCampaign(SS_HTTPRequest $request) {
|
||||
public function publishCampaign(HTTPRequest $request) {
|
||||
// Protect against CSRF on destructive action
|
||||
if(!SecurityToken::inst()->checkRequest($request)) {
|
||||
return (new SS_HTTPResponse(null, 400));
|
||||
return (new HTTPResponse(null, 400));
|
||||
}
|
||||
|
||||
$id = $request->param('ID');
|
||||
if(!$id || !is_numeric($id)) {
|
||||
return (new SS_HTTPResponse(null, 400));
|
||||
return (new HTTPResponse(null, 400));
|
||||
}
|
||||
|
||||
/** @var ChangeSet $record */
|
||||
$record = ChangeSet::get()->byID($id);
|
||||
if(!$record) {
|
||||
return (new SS_HTTPResponse(null, 404));
|
||||
return (new HTTPResponse(null, 404));
|
||||
}
|
||||
|
||||
if(!$record->canPublish()) {
|
||||
return (new SS_HTTPResponse(null, 403));
|
||||
return (new HTTPResponse(null, 403));
|
||||
}
|
||||
|
||||
try {
|
||||
$record->publish();
|
||||
} catch(LogicException $e) {
|
||||
return (new SS_HTTPResponse(json_encode(['status' => 'error', 'message' => $e->getMessage()]), 401))
|
||||
return (new HTTPResponse(json_encode(['status' => 'error', 'message' => $e->getMessage()]), 401))
|
||||
->addHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
return (new SS_HTTPResponse(
|
||||
return (new HTTPResponse(
|
||||
Convert::raw2json($this->getChangeSetResource($record)),
|
||||
200
|
||||
))->addHeader('Content-Type', 'application/json');
|
||||
@ -475,7 +475,7 @@ JSON;
|
||||
/**
|
||||
* Url handler for edit form
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return Form
|
||||
*/
|
||||
public function DetailEditForm($request) {
|
||||
|
@ -9,15 +9,15 @@ use SilverStripe\CMS\Model\VirtualPage;
|
||||
use SilverStripe\CMS\Controllers\SilverStripeNavigator;
|
||||
use SilverStripe\Control\ContentNegotiator;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\PjaxResponseNegotiator;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\SS_Cache;
|
||||
use SilverStripe\Core\Cache;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
@ -300,8 +300,8 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
*
|
||||
* WARNING: Experimental API.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function schema($request) {
|
||||
$response = $this->getResponse();
|
||||
@ -309,15 +309,15 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
$itemID = $request->param('ItemID');
|
||||
|
||||
if (!$formName) {
|
||||
return (new SS_HTTPResponse('Missing request params', 400));
|
||||
return (new HTTPResponse('Missing request params', 400));
|
||||
}
|
||||
|
||||
if(!$this->hasMethod("get{$formName}")) {
|
||||
return (new SS_HTTPResponse('Form not found', 404));
|
||||
return (new HTTPResponse('Form not found', 404));
|
||||
}
|
||||
|
||||
if(!$this->hasAction($formName)) {
|
||||
return (new SS_HTTPResponse('Form not accessible', 401));
|
||||
return (new HTTPResponse('Form not accessible', 401));
|
||||
}
|
||||
|
||||
$form = $this->{"get{$formName}"}($itemID);
|
||||
@ -333,13 +333,13 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
* schema if X-Formschema-Request header is set.
|
||||
*
|
||||
* @param Form $form
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
protected function getSchemaResponse($form) {
|
||||
$request = $this->getRequest();
|
||||
if($request->getHeader('X-Formschema-Request')) {
|
||||
$data = $this->getSchemaForForm($form);
|
||||
$response = new SS_HTTPResponse(Convert::raw2json($data));
|
||||
$response = new HTTPResponse(Convert::raw2json($data));
|
||||
$response->addHeader('Content-Type', 'application/json');
|
||||
return $response;
|
||||
}
|
||||
@ -654,14 +654,14 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
Versioned::set_stage(Versioned::DRAFT);
|
||||
}
|
||||
|
||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model = null) {
|
||||
public function handleRequest(HTTPRequest $request, DataModel $model = null) {
|
||||
try {
|
||||
$response = parent::handleRequest($request, $model);
|
||||
} catch(ValidationException $e) {
|
||||
// Nicer presentation of model-level validation errors
|
||||
$msgs = _t('LeftAndMain.ValidationError', 'Validation error') . ': '
|
||||
. $e->getMessage();
|
||||
$e = new SS_HTTPResponse_Exception($msgs, 403);
|
||||
$e = new HTTPResponse_Exception($msgs, 403);
|
||||
$errorResponse = $e->getResponse();
|
||||
$errorResponse->addHeader('Content-Type', 'text/plain');
|
||||
$errorResponse->addHeader('X-Status', rawurlencode($msgs));
|
||||
@ -691,7 +691,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $code
|
||||
* @return SS_HTTPResponse|string
|
||||
* @return HTTPResponse|string
|
||||
*/
|
||||
public function redirect($url, $code=302) {
|
||||
if($this->getRequest()->isAjax()) {
|
||||
@ -717,8 +717,8 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function index($request) {
|
||||
return $this->getResponseNegotiator()->respond($request);
|
||||
@ -817,9 +817,9 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public function show($request) {
|
||||
// TODO Necessary for TableListField URLs to work properly
|
||||
@ -1210,7 +1210,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
* Get a subtree underneath the request param 'ID'.
|
||||
* If ID = 0, then get the whole tree.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return string
|
||||
*/
|
||||
public function getsubtree($request) {
|
||||
@ -1236,7 +1236,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
* all children with the node. Useful to refresh views after
|
||||
* state modifications, e.g. saving a form.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param HTTPRequest $request
|
||||
* @return string JSON
|
||||
*/
|
||||
public function updatetreenodes($request) {
|
||||
@ -1289,7 +1289,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
*
|
||||
* @param array $data
|
||||
* @param Form $form
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function save($data, $form) {
|
||||
$request = $this->getRequest();
|
||||
@ -1324,7 +1324,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
$form->loadDataFrom($record);
|
||||
$form->setMessage($message, 'good');
|
||||
$data = $this->getSchemaForForm($form);
|
||||
$response = new SS_HTTPResponse(Convert::raw2json($data));
|
||||
$response = new HTTPResponse(Convert::raw2json($data));
|
||||
$response->addHeader('Content-Type', 'application/json');
|
||||
} else {
|
||||
$response = $this->getResponseNegotiator()->respond($request);
|
||||
@ -1377,9 +1377,9 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
* - 'SiblingIDs': Array of all sibling nodes to the moved node (incl. the node itself).
|
||||
* In case of a 'ParentID' change, relates to the new siblings under the new parent.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse JSON string with a
|
||||
* @throws SS_HTTPResponse_Exception
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse JSON string with a
|
||||
* @throws HTTPResponse_Exception
|
||||
*/
|
||||
public function savetreenode($request) {
|
||||
if (!SecurityToken::inst()->checkRequest($request)) {
|
||||
@ -1493,7 +1493,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
* The form usually construct itself from {@link DataObject->getCMSFields()}
|
||||
* for the specific managed subclass defined in {@link LeftAndMain::$tree_class}.
|
||||
*
|
||||
* @param SS_HTTPRequest $request Optionally contains an identifier for the
|
||||
* @param HTTPRequest $request Optionally contains an identifier for the
|
||||
* record to load into the form.
|
||||
* @return Form Should return a form regardless wether a record has been found.
|
||||
* Form might be readonly if the current user doesn't have the permission to edit
|
||||
@ -1906,7 +1906,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
// Tries to obtain version number from composer.lock if it exists
|
||||
$composerLockPath = BASE_PATH . '/composer.lock';
|
||||
if (file_exists($composerLockPath)) {
|
||||
$cache = SS_Cache::factory('LeftAndMain_CMSVersion');
|
||||
$cache = Cache::factory('LeftAndMain_CMSVersion');
|
||||
$cacheKey = filemtime($composerLockPath);
|
||||
$versions = $cache->load($cacheKey);
|
||||
if($versions) {
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
namespace SilverStripe\Admin;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
|
||||
/**
|
||||
* Allow overriding finished state for faux redirects.
|
||||
*/
|
||||
class LeftAndMain_HTTPResponse extends SS_HTTPResponse
|
||||
class LeftAndMain_HTTPResponse extends HTTPResponse
|
||||
{
|
||||
|
||||
protected $isFinished = false;
|
||||
|
@ -3,8 +3,8 @@
|
||||
namespace SilverStripe\Admin;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Dev\BulkLoader;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
@ -433,8 +433,8 @@ abstract class ModelAdmin extends LeftAndMain {
|
||||
*
|
||||
* @param array $data
|
||||
* @param Form $form
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return bool|SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return bool|HTTPResponse
|
||||
*/
|
||||
public function import($data, $form, $request) {
|
||||
if(!$this->showImportForm || (is_array($this->showImportForm)
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace SilverStripe\Admin;
|
||||
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Forms\GridField\GridFieldDataColumns;
|
||||
use SilverStripe\Forms\GridField\GridFieldDetailForm;
|
||||
@ -63,8 +63,8 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
||||
/**
|
||||
* Shortcut action for setting the correct active tab.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function users($request) {
|
||||
return $this->index($request);
|
||||
@ -73,8 +73,8 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
||||
/**
|
||||
* Shortcut action for setting the correct active tab.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function groups($request) {
|
||||
return $this->index($request);
|
||||
@ -83,8 +83,8 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
||||
/**
|
||||
* Shortcut action for setting the correct active tab.
|
||||
*
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return SS_HTTPResponse
|
||||
* @param HTTPRequest $request
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
public function roles($request) {
|
||||
return $this->index($request);
|
||||
|
@ -157,7 +157,7 @@ class LeftAndMainTest extends FunctionalTest {
|
||||
|
||||
$response = $this->get($link);
|
||||
|
||||
$this->assertInstanceOf('SilverStripe\\Control\\SS_HTTPResponse', $response, "$link should return a response object");
|
||||
$this->assertInstanceOf('SilverStripe\\Control\\HTTPResponse', $response, "$link should return a response object");
|
||||
$this->assertEquals(200, $response->getStatusCode(), "$link should return 200 status code");
|
||||
// Check that a HTML page has been returned
|
||||
$this->assertRegExp('/<html[^>]*>/i', $response->getBody(), "$link should contain <html> tag");
|
||||
|
@ -65,7 +65,7 @@ You need to be logged in as an administrator to perform this command, unless you
|
||||
or the command is run through [CLI](../cli).
|
||||
</div>
|
||||
|
||||
When rebuilding the database schema through the [api:SS_ClassLoader] the following additional properties are
|
||||
When rebuilding the database schema through the [api:ClassLoader] the following additional properties are
|
||||
automatically set on the `DataObject`.
|
||||
|
||||
* ID: Primary Key. When a new record is created, SilverStripe does not use the database's built-in auto-numbering
|
||||
|
@ -50,11 +50,11 @@ A map is an array where the array indexes contain data as well as the values. Yo
|
||||
// 3 => 'Will'
|
||||
// );
|
||||
|
||||
This functionality is provided by the [api:SS_Map] class, which can be used to build a map around any `SS_List`.
|
||||
This functionality is provided by the [api:Map] class, which can be used to build a map around any `SS_List`.
|
||||
|
||||
:::php
|
||||
$members = Member::get();
|
||||
$map = new SS_Map($members, 'ID', 'FirstName');
|
||||
$map = new Map($members, 'ID', 'FirstName');
|
||||
|
||||
## Column
|
||||
|
||||
@ -91,4 +91,4 @@ This functionality is provided by the [api:SS_Map] class, which can be used to b
|
||||
* [api:RelationList]
|
||||
* [api:DataList]
|
||||
* [api:ArrayList]
|
||||
* [api:SS_Map]
|
||||
* [api:Map]
|
||||
|
@ -4,7 +4,7 @@ title: How to Create a Paginated List
|
||||
|
||||
In order to create a paginated list, create a method on your controller that first creates a `SS_List` that contains
|
||||
all your record, then wraps it in a [api:PaginatedList] object. The `PaginatedList` object should also passed the
|
||||
[api:SS_HTTPRequest] object so it can read the current page information from the "?start=" GET var.
|
||||
[api:HTTPRequest] object so it can read the current page information from the "?start=" GET var.
|
||||
|
||||
The `PaginatedList` will automatically set up query limits and read the request for information.
|
||||
|
||||
|
@ -18,11 +18,11 @@ subclass the base `Controller` class.
|
||||
'index'
|
||||
);
|
||||
|
||||
public function index(SS_HTTPRequest $request) {
|
||||
public function index(HTTPRequest $request) {
|
||||
// ..
|
||||
}
|
||||
|
||||
public function players(SS_HTTPRequest $request) {
|
||||
public function players(HTTPRequest $request) {
|
||||
print_r($request->allParams());
|
||||
}
|
||||
}
|
||||
@ -67,10 +67,10 @@ It is standard in SilverStripe for your controller actions to be `lowercasewithn
|
||||
|
||||
Action methods can return one of four main things:
|
||||
|
||||
* an array. In this case the values in the array are available in the templates and the controller completes as usual by returning a [api:SS_HTTPResponse] with the body set to the current template.
|
||||
* `HTML`. SilverStripe will wrap the `HTML` into a `SS_HTTPResponse` and set the status code to 200.
|
||||
* an [api:SS_HTTPResponse] containing a manually defined `status code` and `body`.
|
||||
* an [api:SS_HTTPResponse_Exception]. A special type of response which indicates an error. By returning the exception, the execution pipeline can adapt and display any error handlers.
|
||||
* an array. In this case the values in the array are available in the templates and the controller completes as usual by returning a [api:HTTPResponse] with the body set to the current template.
|
||||
* `HTML`. SilverStripe will wrap the `HTML` into a `HTTPResponse` and set the status code to 200.
|
||||
* an [api:HTTPResponse] containing a manually defined `status code` and `body`.
|
||||
* an [api:HTTPResponse_Exception]. A special type of response which indicates an error. By returning the exception, the execution pipeline can adapt and display any error handlers.
|
||||
|
||||
**mysite/code/controllers/TeamController.php**
|
||||
|
||||
@ -79,7 +79,7 @@ Action methods can return one of four main things:
|
||||
* Return some additional data to the current response that is waiting to go out, this makes $Title set to
|
||||
* 'MyTeamName' and continues on with generating the response.
|
||||
*/
|
||||
public function index(SS_HTTPRequest $request) {
|
||||
public function index(HTTPRequest $request) {
|
||||
return array(
|
||||
'Title' => 'My Team Name'
|
||||
);
|
||||
@ -88,8 +88,8 @@ Action methods can return one of four main things:
|
||||
/**
|
||||
* We can manually create a response and return that to ignore any previous data.
|
||||
*/
|
||||
public function someaction(SS_HTTPRequest $request) {
|
||||
$this->setResponse(new SS_HTTPResponse());
|
||||
public function someaction(HTTPRequest $request) {
|
||||
$this->setResponse(new HTTPResponse());
|
||||
$this->getResponse()->setStatusCode(400);
|
||||
$this->getResponse()->setBody('invalid');
|
||||
|
||||
@ -99,7 +99,7 @@ Action methods can return one of four main things:
|
||||
/**
|
||||
* Or, we can modify the response that is waiting to go out.
|
||||
*/
|
||||
public function anotheraction(SS_HTTPRequest $request) {
|
||||
public function anotheraction(HTTPRequest $request) {
|
||||
$this->getResponse()->setStatusCode(400);
|
||||
|
||||
return $this->getResponse();
|
||||
|
@ -40,7 +40,7 @@ To understand the syntax for the `routes.yml` file better, read the [Configurati
|
||||
This route has defined that any URL beginning with `team` should create, and be handled by a `TeamController` instance.
|
||||
|
||||
It also contains 3 `parameters` or `params` for short. `$Action`, `$ID` and `$Name`. These variables are placeholders
|
||||
which will be filled when the user makes their request. Request parameters are available on the `SS_HTTPRequest` object
|
||||
which will be filled when the user makes their request. Request parameters are available on the `HTTPRequest` object
|
||||
and able to be pulled out from a controller using `$this->getRequest()->param($name)`.
|
||||
|
||||
<div class="info" markdown="1">
|
||||
|
@ -172,7 +172,7 @@ replacement.
|
||||
## Controller Level Checks
|
||||
|
||||
After checking for allowed_actions, each controller invokes its `init()` method, which is typically used to set up
|
||||
common state, If an `init()` method returns a `SS_HTTPResponse` with either a 3xx or 4xx HTTP status code, it'll abort
|
||||
common state, If an `init()` method returns a `HTTPResponse` with either a 3xx or 4xx HTTP status code, it'll abort
|
||||
execution. This behavior can be used to implement permission checks.
|
||||
|
||||
<div class="info" markdown="1">
|
||||
|
@ -14,7 +14,7 @@ perform operations wrapped around responses and request objects. A `RequestFilte
|
||||
|
||||
class CustomRequestFilter implements RequestFilter {
|
||||
|
||||
public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model) {
|
||||
public function preRequest(HTTPRequest $request, Session $session, DataModel $model) {
|
||||
|
||||
// if(!something) {
|
||||
// By returning 'false' from the preRequest method, request execution will be stopped from continuing.
|
||||
@ -28,7 +28,7 @@ perform operations wrapped around responses and request objects. A `RequestFilte
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model) {
|
||||
public function postRequest(HTTPRequest $request, HTTPResponse $response, DataModel $model) {
|
||||
// response is about to be sent.
|
||||
// any modifications or tracking to be done?
|
||||
// Foo::unbar();
|
||||
|
@ -2,8 +2,8 @@ title: Controllers
|
||||
summary: Controllers form the backbone of your SilverStripe application. They handle routing URLs to your templates.
|
||||
introduction: In this guide you will learn how to define a Controller class and how they fit into the SilverStripe response and request cycle.
|
||||
|
||||
The [api:Controller] class handles the responsibility of delivering the correct outgoing [api:SS_HTTPResponse] for a
|
||||
given incoming [api:SS_HTTPRequest]. A request is along the lines of a user requesting the homepage and contains
|
||||
The [api:Controller] class handles the responsibility of delivering the correct outgoing [api:HTTPResponse] for a
|
||||
given incoming [api:HTTPRequest]. A request is along the lines of a user requesting the homepage and contains
|
||||
information like the URL, any parameters and where they've come from. The response on the other hand is the actual
|
||||
content of the homepage and the HTTP information we want to give back to the user.
|
||||
|
||||
@ -19,5 +19,5 @@ performing and navigating around the permission checks on the users actions.
|
||||
## API Documentation
|
||||
|
||||
* [api:Controller]
|
||||
* [api:SS_HTTPRequest]
|
||||
* [api:SS_HTTPResponse]
|
||||
* [api:HTTPRequest]
|
||||
* [api:HTTPResponse]
|
||||
|
@ -207,7 +207,7 @@ By default, TinyMCE and SilverStripe will generate valid HTML5 markup, but it wi
|
||||
`<article>` or `<figure>`. If you plan to use those, add them to the
|
||||
[valid_elements](http://www.tinymce.com/wiki.php/Configuration:valid_elements) configuration setting.
|
||||
|
||||
Also, the [api:SS_HTMLValue] API underpinning the HTML processing parses the markup into a temporary object tree
|
||||
Also, the [api:HTMLValue] API underpinning the HTML processing parses the markup into a temporary object tree
|
||||
which can be traversed and modified before saving. The built-in parser only supports HTML4 and XHTML syntax. In order
|
||||
to successfully process HTML5 tags, please use the
|
||||
['silverstripe/html5' module](https://github.com/silverstripe/silverstripe-html5).
|
||||
|
@ -5,14 +5,14 @@ summary: Test controllers, forms and HTTP responses.
|
||||
|
||||
[api:FunctionalTest] test your applications `Controller` logic and anything else which requires a web request. The
|
||||
core idea of these tests is the same as `SapphireTest` unit tests but `FunctionalTest` adds several methods for
|
||||
creating [api:SS_HTTPRequest], receiving [api:SS_HTTPResponse] objects and modifying the current user session.
|
||||
creating [api:HTTPRequest], receiving [api:HTTPResponse] objects and modifying the current user session.
|
||||
|
||||
## Get
|
||||
|
||||
:::php
|
||||
$page = $this->get($url);
|
||||
|
||||
Performs a GET request on $url and retrieves the [api:SS_HTTPResponse]. This also changes the current page to the value
|
||||
Performs a GET request on $url and retrieves the [api:HTTPResponse]. This also changes the current page to the value
|
||||
of the response.
|
||||
|
||||
## Post
|
||||
@ -20,7 +20,7 @@ of the response.
|
||||
:::php
|
||||
$page = $this->post($url);
|
||||
|
||||
Performs a POST request on $url and retrieves the [api:SS_HTTPResponse]. This also changes the current page to the value
|
||||
Performs a POST request on $url and retrieves the [api:HTTPResponse]. This also changes the current page to the value
|
||||
of the response.
|
||||
|
||||
## Submit
|
||||
@ -28,7 +28,7 @@ of the response.
|
||||
:::php
|
||||
$submit = $this->submitForm($formID, $button = null, $data = array());
|
||||
|
||||
Submits the given form (`#ContactForm`) on the current page and returns the [api:SS_HTTPResponse].
|
||||
Submits the given form (`#ContactForm`) on the current page and returns the [api:HTTPResponse].
|
||||
|
||||
## LogInAs
|
||||
|
||||
|
@ -3,8 +3,8 @@ title: How to write a FunctionalTest
|
||||
# How to Write a FunctionalTest
|
||||
|
||||
[api:FunctionalTest] test your applications `Controller` instances and anything else which requires a web request. The
|
||||
core of these tests are the same as `SapphireTest` unit tests but add several methods for creating [api:SS_HTTPRequest]
|
||||
and receiving [api:SS_HTTPResponse] objects. In this How To, we'll see how to write a test to query a page, check the
|
||||
core of these tests are the same as `SapphireTest` unit tests but add several methods for creating [api:HTTPRequest]
|
||||
and receiving [api:HTTPResponse] objects. In this How To, we'll see how to write a test to query a page, check the
|
||||
response and modify the session within a test.
|
||||
|
||||
**mysite/tests/HomePageTest.php**
|
||||
|
@ -24,11 +24,11 @@ The [api:Debug] class contains a number of static utility methods for more advan
|
||||
Debug::message("Wow, that's great");
|
||||
// prints a short debugging message.
|
||||
|
||||
SS_Backtrace::backtrace();
|
||||
Backtrace::backtrace();
|
||||
// prints a calls-stack
|
||||
|
||||
## API Documentation
|
||||
|
||||
* [api:SS_Log]
|
||||
* [api:SS_Backtrace]
|
||||
* [api:Backtrace]
|
||||
* [api:Debug]
|
@ -4,13 +4,13 @@
|
||||
|
||||
The framework uses caches to store infrequently changing values.
|
||||
By default, the storage mechanism is simply the filesystem, although
|
||||
other cache backends can be configured. All caches use the [api:SS_Cache] API.
|
||||
other cache backends can be configured. All caches use the [api:Cache] API.
|
||||
|
||||
The most common caches are manifests of various resources:
|
||||
|
||||
* PHP class locations ([api:SS_ClassManifest])
|
||||
* PHP class locations ([api:ClassManifest])
|
||||
* Template file locations and compiled templates ([api:SS_TemplateManifest])
|
||||
* Configuration settings from YAML files ([api:SS_ConfigManifest])
|
||||
* Configuration settings from YAML files ([api:ConfigManifest])
|
||||
* Language files ([api:i18n])
|
||||
|
||||
Flushing the various manifests is performed through a GET
|
||||
@ -23,7 +23,7 @@ executing the action is limited to the following cases when performed via a web
|
||||
|
||||
## The Cache API
|
||||
|
||||
The [api:SS_Cache] class provides a bunch of static functions wrapping the Zend_Cache system
|
||||
The [api:Cache] class provides a bunch of static functions wrapping the Zend_Cache system
|
||||
in something a little more easy to use with the SilverStripe config system.
|
||||
|
||||
A `Zend_Cache` has both a frontend (determines how to get the value to cache,
|
||||
@ -42,13 +42,13 @@ backend for each named cache. There is a default File cache set up as the
|
||||
|
||||
## Using Caches
|
||||
|
||||
Caches can be created and retrieved through the `SS_Cache::factory()` method.
|
||||
Caches can be created and retrieved through the `Cache::factory()` method.
|
||||
The returned object is of type `Zend_Cache`.
|
||||
|
||||
:::php
|
||||
// foo is any name (try to be specific), and is used to get configuration
|
||||
// & storage info
|
||||
$cache = SS_Cache::factory('foo');
|
||||
$cache = Cache::factory('foo');
|
||||
if (!($result = $cache->load($cachekey))) {
|
||||
$result = caluate some how;
|
||||
$cache->save($result, $cachekey);
|
||||
@ -63,20 +63,20 @@ e.g. in development mode.
|
||||
|
||||
:::php
|
||||
// Disables all caches
|
||||
SS_Cache::set_cache_lifetime('any', -1, 100);
|
||||
Cache::set_cache_lifetime('any', -1, 100);
|
||||
|
||||
You can also specifically clean a cache.
|
||||
Keep in mind that `Zend_Cache::CLEANING_MODE_ALL` deletes all cache
|
||||
entries across all caches, not just for the 'foo' cache in the example below.
|
||||
|
||||
:::php
|
||||
$cache = SS_Cache::factory('foo');
|
||||
$cache = Cache::factory('foo');
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||
|
||||
A single element can be invalidated through its cache key.
|
||||
|
||||
:::php
|
||||
$cache = SS_Cache::factory('foo');
|
||||
$cache = Cache::factory('foo');
|
||||
$cache->remove($cachekey);
|
||||
|
||||
In order to increase the chance of your cache actually being hit,
|
||||
@ -88,7 +88,7 @@ e.g. by including the `LastEdited` value when caching `DataObject` results.
|
||||
|
||||
:::php
|
||||
// set all caches to 3 hours
|
||||
SS_Cache::set_cache_lifetime('any', 60*60*3);
|
||||
Cache::set_cache_lifetime('any', 60*60*3);
|
||||
|
||||
## Alternative Cache Backends
|
||||
|
||||
@ -113,7 +113,7 @@ To use this backend, you need a memcached daemon and the memcache PECL extension
|
||||
|
||||
:::php
|
||||
// _config.php
|
||||
SS_Cache::add_backend(
|
||||
Cache::add_backend(
|
||||
'primary_memcached',
|
||||
'Memcached',
|
||||
array(
|
||||
@ -129,7 +129,7 @@ To use this backend, you need a memcached daemon and the memcache PECL extension
|
||||
)
|
||||
)
|
||||
);
|
||||
SS_Cache::pick_backend('primary_memcached', 'any', 10);
|
||||
Cache::pick_backend('primary_memcached', 'any', 10);
|
||||
|
||||
### APC
|
||||
|
||||
@ -137,8 +137,8 @@ This backends stores cache records in shared memory through the [APC](http://pec
|
||||
(Alternative PHP Cache) extension (which is of course need for using this backend).
|
||||
|
||||
:::php
|
||||
SS_Cache::add_backend('primary_apc', 'APC');
|
||||
SS_Cache::pick_backend('primary_apc', 'any', 10);
|
||||
Cache::add_backend('primary_apc', 'APC');
|
||||
Cache::pick_backend('primary_apc', 'any', 10);
|
||||
|
||||
### Two-Levels
|
||||
|
||||
@ -146,11 +146,11 @@ This backend is an hybrid one. It stores cache records in two other backends:
|
||||
a fast one (but limited) like Apc, Memcache... and a "slow" one like File or Sqlite.
|
||||
|
||||
:::php
|
||||
SS_Cache::add_backend('two_level', 'Two-Levels', array(
|
||||
Cache::add_backend('two_level', 'Two-Levels', array(
|
||||
'slow_backend' => 'File',
|
||||
'fast_backend' => 'APC',
|
||||
'slow_backend_options' => array(
|
||||
'cache_dir' => TEMP_FOLDER . DIRECTORY_SEPARATOR . 'cache'
|
||||
)
|
||||
));
|
||||
SS_Cache::pick_backend('two_level', 'any', 10);
|
||||
Cache::pick_backend('two_level', 'any', 10);
|
||||
|
@ -103,7 +103,7 @@ and [datamodel](/developer_guides/model) for ways to parameterise, cast, and con
|
||||
* `DB::prepared_query()`
|
||||
* `Director::urlParams()`
|
||||
* `Controller->requestParams`, `Controller->urlParams`
|
||||
* `SS_HTTPRequest` data
|
||||
* `HTTPRequest` data
|
||||
* GET/POST data passed to a form method
|
||||
|
||||
Example:
|
||||
|
@ -112,7 +112,7 @@ the `$fields` constructor parameter.
|
||||
For pagination records on multiple pages, you need to wrap the results in a
|
||||
`PaginatedList` object. This object is also passed the generated `SQLSelect`
|
||||
in order to read page limit information. It is also passed the current
|
||||
`SS_HTTPRequest` object so it can read the current page from a GET var.
|
||||
`HTTPRequest` object so it can read the current page from a GET var.
|
||||
|
||||
:::php
|
||||
public function getResults($searchCriteria = array()) {
|
||||
|
@ -14,20 +14,20 @@ implementors of [api:Flushable].
|
||||
To use this API, you need to make your class implement [api:Flushable], and define a `flush()` static function,
|
||||
this defines the actions that need to be executed on a flush request.
|
||||
|
||||
### Using with SS_Cache
|
||||
### Using with Cache
|
||||
|
||||
This example uses [api:SS_Cache] in some custom code, and the same cache is cleaned on flush:
|
||||
This example uses [api:Cache] in some custom code, and the same cache is cleaned on flush:
|
||||
|
||||
:::php
|
||||
<?php
|
||||
class MyClass extends DataObject implements Flushable {
|
||||
|
||||
public static function flush() {
|
||||
SS_Cache::factory('mycache')->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||
Cache::factory('mycache')->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||
}
|
||||
|
||||
public function MyCachedContent() {
|
||||
$cache = SS_Cache::factory('mycache')
|
||||
$cache = Cache::factory('mycache')
|
||||
$something = $cache->load('mykey');
|
||||
if(!$something) {
|
||||
$something = 'value to be cached';
|
||||
|
@ -26,7 +26,7 @@ You can write your own adapters by implementing the `ManifestCache` interface.
|
||||
## Traversing the Filesystem
|
||||
|
||||
Since manifests usually extract their information from files in the webroot,
|
||||
they require a powerful traversal tool: [api:SS_FileFinder].
|
||||
they require a powerful traversal tool: [api:FileFinder].
|
||||
The class provides filtering abilities for files and folders, as well as
|
||||
callbacks for recursive traversal. Each manifest has its own implementation,
|
||||
for example [api:ManifestFileFinder], adding more domain specific filtering
|
||||
@ -44,7 +44,7 @@ It finds the following information:
|
||||
* All implementors of an interface
|
||||
* All module configuration files
|
||||
|
||||
The gathered information can be accessed through [api:SS_ClassLoader::instance()],
|
||||
The gathered information can be accessed through [api:ClassLoader::instance()],
|
||||
as well as [api:ClassInfo]. Some useful commands of the `ClassInfo` API:
|
||||
|
||||
* `ClassInfo::subclassesFor($class)`: Returns a list of classes that inherit from the given class
|
||||
@ -69,7 +69,7 @@ on its operation.
|
||||
|
||||
## Config Manifest
|
||||
|
||||
The [api:SS_ConfigManifest] loads builds a manifest of configuration items,
|
||||
The [api:ConfigManifest] loads builds a manifest of configuration items,
|
||||
for both PHP and YAML. It also takes care of ordering and merging configuration fragments.
|
||||
The chapter on [configuration](../configuration) has more details.
|
||||
|
||||
|
@ -106,13 +106,13 @@ before handing control off to SilverStripe's own `main.php`.
|
||||
The `main.php` script relies on [api:Director] to work out which [controller](../controllers/) should handle this request. It parses the URL, matching it to one of a number of patterns,
|
||||
and determines the controller, action and any argument to be used ([Routing](../controllers/routing)).
|
||||
|
||||
* Creates a [api:SS_HTTPRequest] object containing all request and environment information
|
||||
* Creates a [api:HTTPRequest] object containing all request and environment information
|
||||
* The [session](../cookies_and_sessions/sessions) holds an abstraction of PHP session
|
||||
* Instantiates a [controller](../controllers/) object
|
||||
* The [api:Injector] is first referenced, and asks the registered
|
||||
[RequestFilter](../controllers/requestfilters)
|
||||
to pre-process the request object (see below)
|
||||
* The `Controller` executes the actual business logic and populates an [api:SS_HTTPResponse]
|
||||
* The `Controller` executes the actual business logic and populates an [api:HTTPResponse]
|
||||
* The `Controller` can optionally hand off control to further nested controllers
|
||||
* The `Controller` optionally renders a response body through `SSViewer` [templates](../templates)
|
||||
* The [api:RequestProcessor] is called to post-process the request to allow
|
||||
|
@ -3,12 +3,12 @@
|
||||
namespace SilverStripe\i18n;
|
||||
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\SS_Cache;
|
||||
use SilverStripe\Core\Cache;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\Core\Flushable;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\View\TemplateGlobalProvider;
|
||||
use Zend_Cache_Backend_ExtendedInterface;
|
||||
@ -140,7 +140,7 @@ class i18n extends Object implements TemplateGlobalProvider, Flushable {
|
||||
* @return Zend_Cache_Core
|
||||
*/
|
||||
public static function get_cache() {
|
||||
return SS_Cache::factory('i18n', 'Output', array('lifetime' => null, 'automatic_serialization' => true));
|
||||
return Cache::factory('i18n', 'Output', array('lifetime' => null, 'automatic_serialization' => true));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2268,7 +2268,7 @@ class i18n extends Object implements TemplateGlobalProvider, Flushable {
|
||||
$locales = array();
|
||||
|
||||
// TODO Inspect themes
|
||||
$modules = SS_ClassLoader::instance()->getManifest()->getModules();
|
||||
$modules = ClassLoader::instance()->getManifest()->getModules();
|
||||
|
||||
foreach($modules as $module) {
|
||||
if(!file_exists("{$module}/lang/")) continue;
|
||||
@ -2407,7 +2407,7 @@ class i18n extends Object implements TemplateGlobalProvider, Flushable {
|
||||
* @return string
|
||||
*/
|
||||
public static function get_owner_module($name) {
|
||||
$manifest = SS_ClassLoader::instance()->getManifest();
|
||||
$manifest = ClassLoader::instance()->getManifest();
|
||||
$path = $manifest->getItemPath($name);
|
||||
|
||||
if (!$path) {
|
||||
@ -2500,7 +2500,7 @@ class i18n extends Object implements TemplateGlobalProvider, Flushable {
|
||||
}
|
||||
|
||||
// Get list of module => path pairs, and then just the names
|
||||
$modules = SS_ClassLoader::instance()->getManifest()->getModules();
|
||||
$modules = ClassLoader::instance()->getManifest()->getModules();
|
||||
$moduleNames = array_keys($modules);
|
||||
|
||||
// Remove the "project" module from the list - we'll add it back specially later if needed
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\i18n;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Dev\Debug;
|
||||
use SilverStripe\Control\Director;
|
||||
use ReflectionClass;
|
||||
@ -312,7 +312,7 @@ class i18nTextCollector extends Object {
|
||||
// Find FQN that ends with $class
|
||||
$classes = preg_grep(
|
||||
'/'.preg_quote("\\{$class}", '\/').'$/i',
|
||||
SS_ClassLoader::instance()->getManifest()->getClassNames()
|
||||
ClassLoader::instance()->getManifest()->getClassNames()
|
||||
);
|
||||
|
||||
// Find all modules for candidate classes
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\Controller;
|
||||
|
||||
// Fake a current controller. Way harder than it should be
|
||||
@ -16,7 +16,7 @@ class FakeController extends Controller {
|
||||
|
||||
$this->pushCurrent();
|
||||
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
(isset($_SERVER['X-HTTP-Method-Override']))
|
||||
? $_SERVER['X-HTTP-Method-Override']
|
||||
: $_SERVER['REQUEST_METHOD'],
|
||||
@ -24,7 +24,7 @@ class FakeController extends Controller {
|
||||
);
|
||||
$this->setRequest($request);
|
||||
|
||||
$this->setResponse(new SS_HTTPResponse());
|
||||
$this->setResponse(new HTTPResponse());
|
||||
|
||||
$this->doInit();
|
||||
}
|
||||
|
22
tests/cache/CacheTest.php
vendored
22
tests/cache/CacheTest.php
vendored
@ -1,31 +1,31 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\SS_Cache;
|
||||
use SilverStripe\Core\Cache;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
|
||||
class CacheTest extends SapphireTest {
|
||||
|
||||
public function testCacheBasics() {
|
||||
$cache = SS_Cache::factory('test');
|
||||
$cache = Cache::factory('test');
|
||||
|
||||
$cache->save('Good', 'cachekey');
|
||||
$this->assertEquals('Good', $cache->load('cachekey'));
|
||||
}
|
||||
|
||||
public function testCacheCanBeDisabled() {
|
||||
SS_Cache::set_cache_lifetime('test', -1, 10);
|
||||
Cache::set_cache_lifetime('test', -1, 10);
|
||||
|
||||
$cache = SS_Cache::factory('test');
|
||||
$cache = Cache::factory('test');
|
||||
|
||||
$cache->save('Good', 'cachekey');
|
||||
$this->assertFalse($cache->load('cachekey'));
|
||||
}
|
||||
|
||||
public function testCacheLifetime() {
|
||||
SS_Cache::set_cache_lifetime('test', 0.5, 20);
|
||||
Cache::set_cache_lifetime('test', 0.5, 20);
|
||||
|
||||
$cache = SS_Cache::factory('test');
|
||||
$cache = Cache::factory('test');
|
||||
$this->assertEquals(0.5, $cache->getOption('lifetime'));
|
||||
|
||||
$cache->save('Good', 'cachekey');
|
||||
@ -44,8 +44,8 @@ class CacheTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testCacheSeperation() {
|
||||
$cache1 = SS_Cache::factory('test1');
|
||||
$cache2 = SS_Cache::factory('test2');
|
||||
$cache1 = Cache::factory('test1');
|
||||
$cache2 = Cache::factory('test2');
|
||||
|
||||
$cache1->save('Foo', 'cachekey');
|
||||
$cache2->save('Bar', 'cachekey');
|
||||
@ -58,12 +58,12 @@ class CacheTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testCacheDefault() {
|
||||
SS_Cache::set_cache_lifetime('default', 1200);
|
||||
$default = SS_Cache::get_cache_lifetime('default');
|
||||
Cache::set_cache_lifetime('default', 1200);
|
||||
$default = Cache::get_cache_lifetime('default');
|
||||
|
||||
$this->assertEquals(1200, $default['lifetime']);
|
||||
|
||||
$cache = SS_Cache::factory('somethingnew');
|
||||
$cache = Cache::factory('somethingnew');
|
||||
|
||||
$this->assertEquals(1200, $cache->getOption('lifetime'));
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ class ControllerTest extends FunctionalTest {
|
||||
|
||||
public function testUndefinedActions() {
|
||||
$response = $this->get('ControllerTest_IndexSecuredController/undefinedaction');
|
||||
$this->assertInstanceOf('SilverStripe\\Control\\SS_HTTPResponse', $response);
|
||||
$this->assertInstanceOf('SilverStripe\\Control\\HTTPResponse', $response);
|
||||
$this->assertEquals(404, $response->getStatusCode(), 'Undefined actions return a not found response.');
|
||||
}
|
||||
|
||||
@ -416,7 +416,7 @@ class ControllerTest extends FunctionalTest {
|
||||
$response = $this->get("ControllerTest_ContainerController/subcontroller/subaction");
|
||||
$this->assertEquals('subaction', $response->getBody());
|
||||
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'GET',
|
||||
'ControllerTest_ContainerController/subcontroller/substring/subvieweraction'
|
||||
);
|
||||
|
@ -7,9 +7,9 @@ use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\RequestProcessor;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\RequestFilter;
|
||||
use SilverStripe\Control\Controller;
|
||||
|
||||
@ -367,7 +367,7 @@ class DirectorTest extends SapphireTest {
|
||||
Injector::inst()->createWithArgs('SilverStripe\\Control\\Cookie_Backend', array($fixture))
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('SilverStripe\\Control\\SS_HTTPResponse', $getresponse, 'Director::test() returns SS_HTTPResponse');
|
||||
$this->assertInstanceOf('SilverStripe\\Control\\HTTPResponse', $getresponse, 'Director::test() returns HTTPResponse');
|
||||
$this->assertEquals($fixture['somekey'], $getresponse->getBody(), 'Director::test() ' . $testfunction);
|
||||
}
|
||||
}
|
||||
@ -558,7 +558,7 @@ class DirectorTest extends SapphireTest {
|
||||
|
||||
$filter->failPost = true;
|
||||
|
||||
$this->setExpectedException('SilverStripe\\Control\\SS_HTTPResponse_Exception');
|
||||
$this->setExpectedException('SilverStripe\\Control\\HTTPResponse_Exception');
|
||||
|
||||
$response = Director::test('some-dummy-url');
|
||||
|
||||
@ -583,7 +583,7 @@ class TestRequestFilter implements RequestFilter, TestOnly {
|
||||
public $failPre = false;
|
||||
public $failPost = false;
|
||||
|
||||
public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model) {
|
||||
public function preRequest(HTTPRequest $request, Session $session, DataModel $model) {
|
||||
++$this->preCalls;
|
||||
|
||||
if ($this->failPre) {
|
||||
@ -591,7 +591,7 @@ class TestRequestFilter implements RequestFilter, TestOnly {
|
||||
}
|
||||
}
|
||||
|
||||
public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model) {
|
||||
public function postRequest(HTTPRequest $request, HTTPResponse $response, DataModel $model) {
|
||||
++$this->postCalls;
|
||||
|
||||
if ($this->failPost) {
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
|
||||
|
||||
class HTTPRequestTest extends SapphireTest {
|
||||
protected static $fixture_file = null;
|
||||
|
||||
public function testMatch() {
|
||||
$request = new SS_HTTPRequest("GET", "admin/crm/add");
|
||||
$request = new HTTPRequest("GET", "admin/crm/add");
|
||||
|
||||
/* When a rule matches, but has no variables, array("_matched" => true) is returned. */
|
||||
$this->assertEquals(array("_matched" => true), $request->match('admin/crm', true));
|
||||
@ -20,7 +20,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testHttpMethodOverrides() {
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'GET',
|
||||
'admin/crm'
|
||||
);
|
||||
@ -29,7 +29,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
'GET with no method override'
|
||||
);
|
||||
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'admin/crm'
|
||||
);
|
||||
@ -38,7 +38,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
'POST with no method override'
|
||||
);
|
||||
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'GET',
|
||||
'admin/crm',
|
||||
array('_method' => 'DELETE')
|
||||
@ -48,7 +48,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
'GET with invalid POST method override'
|
||||
);
|
||||
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'admin/crm',
|
||||
array(),
|
||||
@ -59,7 +59,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
'POST with valid method override to DELETE'
|
||||
);
|
||||
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'admin/crm',
|
||||
array(),
|
||||
@ -70,7 +70,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
'POST with valid method override to PUT'
|
||||
);
|
||||
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'admin/crm',
|
||||
array(),
|
||||
@ -81,7 +81,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
'POST with valid method override to HEAD '
|
||||
);
|
||||
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'admin/crm',
|
||||
array(),
|
||||
@ -92,7 +92,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
'POST with valid method override to HEAD'
|
||||
);
|
||||
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'admin/crm',
|
||||
array('_method' => 'head')
|
||||
@ -118,7 +118,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
'third' => 'c',
|
||||
'fourth' => 'd',
|
||||
);
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'admin/crm',
|
||||
$getVars,
|
||||
@ -143,7 +143,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
'second' => 'b',
|
||||
'third' => 'd',
|
||||
);
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'admin/crm',
|
||||
$getVars,
|
||||
@ -182,7 +182,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
'third' => 'd',
|
||||
),
|
||||
);
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'admin/crm',
|
||||
$getVars,
|
||||
@ -222,7 +222,7 @@ class HTTPRequestTest extends SapphireTest {
|
||||
'third' => 'd',
|
||||
),
|
||||
);
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'admin/crm',
|
||||
$getVars,
|
||||
@ -236,31 +236,31 @@ class HTTPRequestTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testIsAjax() {
|
||||
$req = new SS_HTTPRequest('GET', '/', array('ajax' => 0));
|
||||
$req = new HTTPRequest('GET', '/', array('ajax' => 0));
|
||||
$this->assertFalse($req->isAjax());
|
||||
|
||||
$req = new SS_HTTPRequest('GET', '/', array('ajax' => 1));
|
||||
$req = new HTTPRequest('GET', '/', array('ajax' => 1));
|
||||
$this->assertTrue($req->isAjax());
|
||||
|
||||
$req = new SS_HTTPRequest('GET', '/');
|
||||
$req = new HTTPRequest('GET', '/');
|
||||
$req->addHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
$this->assertTrue($req->isAjax());
|
||||
}
|
||||
|
||||
public function testGetURL() {
|
||||
$req = new SS_HTTPRequest('GET', '/');
|
||||
$req = new HTTPRequest('GET', '/');
|
||||
$this->assertEquals('', $req->getURL());
|
||||
|
||||
$req = new SS_HTTPRequest('GET', '/assets/somefile.gif');
|
||||
$req = new HTTPRequest('GET', '/assets/somefile.gif');
|
||||
$this->assertEquals('assets/somefile.gif', $req->getURL());
|
||||
|
||||
$req = new SS_HTTPRequest('GET', '/home?test=1');
|
||||
$req = new HTTPRequest('GET', '/home?test=1');
|
||||
$this->assertEquals('home?test=1', $req->getURL(true));
|
||||
$this->assertEquals('home', $req->getURL());
|
||||
}
|
||||
|
||||
public function testGetIPFromHeaderValue() {
|
||||
$req = new SS_HTTPRequest('GET', '/');
|
||||
$req = new HTTPRequest('GET', '/');
|
||||
$reflectionMethod = new ReflectionMethod($req, 'getIPFromHeaderValue');
|
||||
$reflectionMethod->setAccessible(true);
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
|
||||
/**
|
||||
* @package framework
|
||||
@ -11,7 +11,7 @@ use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
class HTTPResponseTest extends SapphireTest {
|
||||
|
||||
public function testStatusDescriptionStripsNewlines() {
|
||||
$r = new SS_HTTPResponse('my body', 200, "my description \nwith newlines \rand carriage returns");
|
||||
$r = new HTTPResponse('my body', 200, "my description \nwith newlines \rand carriage returns");
|
||||
$this->assertEquals(
|
||||
"my description with newlines and carriage returns",
|
||||
$r->getStatusDescription()
|
||||
@ -19,13 +19,13 @@ class HTTPResponseTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testHTTPResponseException() {
|
||||
$response = new SS_HTTPResponse("Test", 200, 'OK');
|
||||
$response = new HTTPResponse("Test", 200, 'OK');
|
||||
|
||||
// Confirm that the exception's statusCode and statusDescription take precedence
|
||||
try {
|
||||
throw new SS_HTTPResponse_Exception($response, 404, 'not even found');
|
||||
throw new HTTPResponse_Exception($response, 404, 'not even found');
|
||||
|
||||
} catch(SS_HTTPResponse_Exception $e) {
|
||||
} catch(HTTPResponse_Exception $e) {
|
||||
$this->assertEquals(404, $e->getResponse()->getStatusCode());
|
||||
$this->assertEquals('not even found', $e->getResponse()->getStatusDescription());
|
||||
return;
|
||||
@ -39,9 +39,9 @@ class HTTPResponseTest extends SapphireTest {
|
||||
|
||||
// Confirm that the exception's statusCode and statusDescription take precedence
|
||||
try {
|
||||
throw new SS_HTTPResponse_Exception("Some content that may be from a hacker", 404, 'not even found');
|
||||
throw new HTTPResponse_Exception("Some content that may be from a hacker", 404, 'not even found');
|
||||
|
||||
} catch(SS_HTTPResponse_Exception $e) {
|
||||
} catch(HTTPResponse_Exception $e) {
|
||||
$this->assertEquals("text/plain", $e->getResponse()->getHeader("Content-Type"));
|
||||
return;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\HTTP;
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ class HTTPTest extends FunctionalTest {
|
||||
|
||||
public function testAddCacheHeaders() {
|
||||
$body = "<html><head></head><body><h1>Mysite</h1></body></html>";
|
||||
$response = new SS_HTTPResponse($body, 200);
|
||||
$response = new HTTPResponse($body, 200);
|
||||
$this->assertEmpty($response->getHeader('Cache-Control'));
|
||||
|
||||
HTTP::set_cache_age(30);
|
||||
@ -27,13 +27,13 @@ class HTTPTest extends FunctionalTest {
|
||||
|
||||
// Ensure max-age is zero for development.
|
||||
Director::config()->update('environment_type', 'dev');
|
||||
$response = new SS_HTTPResponse($body, 200);
|
||||
$response = new HTTPResponse($body, 200);
|
||||
HTTP::add_cache_headers($response);
|
||||
$this->assertContains('max-age=0', $response->getHeader('Cache-Control'));
|
||||
|
||||
// Ensure max-age setting is respected in production.
|
||||
Director::config()->update('environment_type', 'live');
|
||||
$response = new SS_HTTPResponse($body, 200);
|
||||
$response = new HTTPResponse($body, 200);
|
||||
HTTP::add_cache_headers($response);
|
||||
$this->assertContains('max-age=30', explode(', ', $response->getHeader('Cache-Control')));
|
||||
$this->assertNotContains('max-age=0', $response->getHeader('Cache-Control'));
|
||||
@ -44,7 +44,7 @@ class HTTPTest extends FunctionalTest {
|
||||
'Pragma' => 'no-cache',
|
||||
'Cache-Control' => 'max-age=0, no-cache, no-store',
|
||||
);
|
||||
$response = new SS_HTTPResponse($body, 200);
|
||||
$response = new HTTPResponse($body, 200);
|
||||
foreach($headers as $name => $value) {
|
||||
$response->addHeader($name, $value);
|
||||
}
|
||||
@ -56,7 +56,7 @@ class HTTPTest extends FunctionalTest {
|
||||
|
||||
public function testConfigVary() {
|
||||
$body = "<html><head></head><body><h1>Mysite</h1></body></html>";
|
||||
$response = new SS_HTTPResponse($body, 200);
|
||||
$response = new HTTPResponse($body, 200);
|
||||
Director::config()->update('environment_type', 'live');
|
||||
HTTP::set_cache_age(30);
|
||||
HTTP::add_cache_headers($response);
|
||||
@ -71,7 +71,7 @@ class HTTPTest extends FunctionalTest {
|
||||
|
||||
HTTP::config()->update('vary', '');
|
||||
|
||||
$response = new SS_HTTPResponse($body, 200);
|
||||
$response = new HTTPResponse($body, 200);
|
||||
HTTP::add_cache_headers($response);
|
||||
|
||||
$v = $response->getHeader('Vary');
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Control\PjaxResponseNegotiator;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
|
||||
class PjaxResponseNegotiatorTest extends SapphireTest {
|
||||
|
||||
@ -10,7 +10,7 @@ class PjaxResponseNegotiatorTest extends SapphireTest {
|
||||
$negotiator = new PjaxResponseNegotiator(array(
|
||||
'default' => function() {return 'default response';},
|
||||
));
|
||||
$request = new SS_HTTPRequest('GET', '/'); // not setting pjax header
|
||||
$request = new HTTPRequest('GET', '/'); // not setting pjax header
|
||||
$response = $negotiator->respond($request);
|
||||
$this->assertEquals('default response', $response->getBody());
|
||||
}
|
||||
@ -20,7 +20,7 @@ class PjaxResponseNegotiatorTest extends SapphireTest {
|
||||
'default' => function() {return 'default response';},
|
||||
'myfragment' => function() {return 'myfragment response';},
|
||||
));
|
||||
$request = new SS_HTTPRequest('GET', '/');
|
||||
$request = new HTTPRequest('GET', '/');
|
||||
$request->addHeader('X-Pjax', 'myfragment');
|
||||
$response = $negotiator->respond($request);
|
||||
$this->assertEquals('{"myfragment":"myfragment response"}', $response->getBody());
|
||||
@ -32,7 +32,7 @@ class PjaxResponseNegotiatorTest extends SapphireTest {
|
||||
'myfragment' => function() {return 'myfragment response';},
|
||||
'otherfragment' => function() {return 'otherfragment response';},
|
||||
));
|
||||
$request = new SS_HTTPRequest('GET', '/');
|
||||
$request = new HTTPRequest('GET', '/');
|
||||
$request->addHeader('X-Pjax', 'myfragment,otherfragment');
|
||||
$request->addHeader('Accept', 'text/json');
|
||||
$response = $negotiator->respond($request);
|
||||
@ -49,7 +49,7 @@ class PjaxResponseNegotiatorTest extends SapphireTest {
|
||||
'beta' => function() {return 'beta response';}
|
||||
));
|
||||
|
||||
$request = new SS_HTTPRequest('GET', '/');
|
||||
$request = new HTTPRequest('GET', '/');
|
||||
$request->addHeader('X-Pjax', 'alpha');
|
||||
$request->addHeader('Accept', 'text/json');
|
||||
|
||||
|
@ -1,31 +1,24 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Dev\Debug;
|
||||
use SilverStripe\Security\SecurityToken;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\FormAction;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\Security\SecurityToken;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\ViewableData;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tests for RequestHandler and SS_HTTPRequest.
|
||||
* Tests for RequestHandler and HTTPRequest.
|
||||
* We've set up a simple URL handling model based on
|
||||
*/
|
||||
class RequestHandlingTest extends FunctionalTest {
|
||||
@ -74,7 +67,7 @@ class RequestHandlingTest extends FunctionalTest {
|
||||
// public function testRequestHandlerChainingLatestParams() {
|
||||
// $c = new RequestHandlingTest_Controller();
|
||||
// $c->init();
|
||||
// $response = $c->handleRequest(new SS_HTTPRequest('GET', 'testGoodBase1/TestForm/fields/MyField'));
|
||||
// $response = $c->handleRequest(new HTTPRequest('GET', 'testGoodBase1/TestForm/fields/MyField'));
|
||||
// $this->assertEquals(
|
||||
// $c->getRequest()->latestParams(),
|
||||
// array(
|
||||
@ -394,11 +387,11 @@ class RequestHandlingTest_Controller extends Controller implements TestOnly {
|
||||
}
|
||||
|
||||
public function throwexception() {
|
||||
throw new SS_HTTPResponse_Exception('This request was invalid.', 400);
|
||||
throw new HTTPResponse_Exception('This request was invalid.', 400);
|
||||
}
|
||||
|
||||
public function throwresponseexception() {
|
||||
throw new SS_HTTPResponse_Exception(new SS_HTTPResponse('There was an internal server error.', 500));
|
||||
throw new HTTPResponse_Exception(new HTTPResponse('There was an internal server error.', 500));
|
||||
}
|
||||
|
||||
public function throwhttperror() {
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\Manifest\SS_ClassManifest;
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ClassManifest;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
/**
|
||||
* Tests for the {@link SS_ClassManifest} class.
|
||||
* Tests for the {@link ClassManifest} class.
|
||||
*
|
||||
* @package framework
|
||||
* @subpackage tests
|
||||
@ -20,12 +20,12 @@ class ClassLoaderTest extends SapphireTest {
|
||||
|
||||
$this->baseManifest1 = dirname(__FILE__) . '/fixtures/classmanifest';
|
||||
$this->baseManifest2 = dirname(__FILE__) . '/fixtures/classmanifest_other';
|
||||
$this->testManifest1 = new SS_ClassManifest($this->baseManifest1, false, true, false);
|
||||
$this->testManifest2 = new SS_ClassManifest($this->baseManifest2, false, true, false);
|
||||
$this->testManifest1 = new ClassManifest($this->baseManifest1, false, true, false);
|
||||
$this->testManifest2 = new ClassManifest($this->baseManifest2, false, true, false);
|
||||
}
|
||||
|
||||
public function testExclusive() {
|
||||
$loader = new SS_ClassLoader();
|
||||
$loader = new ClassLoader();
|
||||
|
||||
$loader->pushManifest($this->testManifest1);
|
||||
$this->assertTrue((bool)$loader->getItemPath('ClassA'));
|
||||
@ -42,7 +42,7 @@ class ClassLoaderTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testGetItemPath() {
|
||||
$loader = new SS_ClassLoader();
|
||||
$loader = new ClassLoader();
|
||||
|
||||
$loader->pushManifest($this->testManifest1);
|
||||
$this->assertEquals(
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\Manifest\SS_ClassManifest;
|
||||
use SilverStripe\Core\Manifest\ClassManifest;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
/**
|
||||
* Tests for the {@link SS_ClassManifest} class.
|
||||
* Tests for the {@link ClassManifest} class.
|
||||
*
|
||||
* @package framework
|
||||
* @subpackage tests
|
||||
@ -19,8 +19,8 @@ class ClassManifestTest extends SapphireTest {
|
||||
parent::setUp();
|
||||
|
||||
$this->base = dirname(__FILE__) . '/fixtures/classmanifest';
|
||||
$this->manifest = new SS_ClassManifest($this->base, false, true, false);
|
||||
$this->manifestTests = new SS_ClassManifest($this->base, true, true, false);
|
||||
$this->manifest = new ClassManifest($this->base, false, true, false);
|
||||
$this->manifestTests = new ClassManifest($this->base, true, true, false);
|
||||
}
|
||||
|
||||
public function testGetItemPath() {
|
||||
@ -145,7 +145,7 @@ class ClassManifestTest extends SapphireTest {
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testManifestWarnsAboutDuplicateClasses() {
|
||||
$dummy = new SS_ClassManifest(dirname(__FILE__) . '/fixtures/classmanifest_duplicates', false, true, false);
|
||||
$dummy = new ClassManifest(dirname(__FILE__) . '/fixtures/classmanifest_duplicates', false, true, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Manifest\SS_ConfigManifest;
|
||||
use SilverStripe\Core\Manifest\ConfigManifest;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
|
||||
|
||||
class ConfigManifestTest_ConfigManifestAccess extends SS_ConfigManifest {
|
||||
class ConfigManifestTest_ConfigManifestAccess extends ConfigManifest {
|
||||
public function relativeOrder($a, $b) {
|
||||
return parent::relativeOrder($a, $b);
|
||||
}
|
||||
@ -20,7 +20,7 @@ class ConfigManifestTest extends SapphireTest {
|
||||
* @return any
|
||||
*/
|
||||
protected function getConfigFixtureValue($name) {
|
||||
$manifest = new SS_ConfigManifest(dirname(__FILE__).'/fixtures/configmanifest', true, true);
|
||||
$manifest = new ConfigManifest(dirname(__FILE__).'/fixtures/configmanifest', true, true);
|
||||
return $manifest->get('ConfigManifestTest', $name);
|
||||
}
|
||||
|
||||
@ -48,11 +48,11 @@ class ConfigManifestTest extends SapphireTest {
|
||||
/**
|
||||
* A helper method to return a mock of the manifest in order to test expectations and reduce dependency
|
||||
* @param $methods
|
||||
* @return SS_ConfigManifest
|
||||
* @return ConfigManifest
|
||||
*/
|
||||
protected function getManifestMock($methods) {
|
||||
return $this->getMock(
|
||||
'SilverStripe\\Core\\Manifest\\SS_ConfigManifest',
|
||||
'SilverStripe\\Core\\Manifest\\ConfigManifest',
|
||||
$methods,
|
||||
array(), // no constructor arguments
|
||||
'', // default
|
||||
@ -179,7 +179,7 @@ class ConfigManifestTest extends SapphireTest {
|
||||
);
|
||||
|
||||
// There is no getter for yamlConfigFragments
|
||||
$property = new ReflectionProperty('SilverStripe\\Core\\Manifest\\SS_ConfigManifest', 'yamlConfigFragments');
|
||||
$property = new ReflectionProperty('SilverStripe\\Core\\Manifest\\ConfigManifest', 'yamlConfigFragments');
|
||||
$property->setAccessible(true);
|
||||
|
||||
// Get the result back from the parsing
|
||||
@ -419,7 +419,7 @@ class ConfigManifestTest extends SapphireTest {
|
||||
$this->assertEquals('live', Config::inst()->get('SilverStripe\\Control\\Director', 'environment_type'));
|
||||
|
||||
// Then, load in a new manifest, which includes a _config.php that sets environment_type to dev
|
||||
$manifest = new SS_ConfigManifest(dirname(__FILE__).'/fixtures/configmanifest_dynamicenv', true, true);
|
||||
$manifest = new ConfigManifest(dirname(__FILE__).'/fixtures/configmanifest_dynamicenv', true, true);
|
||||
Config::inst()->pushConfigYamlManifest($manifest);
|
||||
|
||||
// Make sure that stuck
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\Manifest\SS_ConfigStaticManifest;
|
||||
use SilverStripe\Core\Manifest\ConfigStaticManifest;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ class ConfigStaticManifestTest extends SapphireTest {
|
||||
protected static $ignored = true;
|
||||
|
||||
public function testGet() {
|
||||
$manifest = new SS_ConfigStaticManifest();
|
||||
$manifest = new ConfigStaticManifest();
|
||||
|
||||
// Test madeup value
|
||||
$this->assertNull($manifest->get(__CLASS__, 'madeup', null));
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Manifest\SS_ClassManifest;
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ClassManifest;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
|
||||
/**
|
||||
* Tests for the {@link SS_ClassManifest} class.
|
||||
* Tests for the {@link ClassManifest} class.
|
||||
*
|
||||
* @package framework
|
||||
* @subpackage tests
|
||||
@ -17,7 +17,7 @@ class NamespacedClassManifestTest extends SapphireTest {
|
||||
protected $base;
|
||||
|
||||
/**
|
||||
* @var SS_ClassManifest
|
||||
* @var ClassManifest
|
||||
*/
|
||||
protected $manifest;
|
||||
|
||||
@ -25,27 +25,27 @@ class NamespacedClassManifestTest extends SapphireTest {
|
||||
parent::setUp();
|
||||
|
||||
$this->base = dirname(__FILE__) . '/fixtures/namespaced_classmanifest';
|
||||
$this->manifest = new SS_ClassManifest($this->base, false, true, false);
|
||||
SS_ClassLoader::instance()->pushManifest($this->manifest, false);
|
||||
$this->manifest = new ClassManifest($this->base, false, true, false);
|
||||
ClassLoader::instance()->pushManifest($this->manifest, false);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
SS_ClassLoader::instance()->popManifest();
|
||||
ClassLoader::instance()->popManifest();
|
||||
}
|
||||
|
||||
public function testGetImportedNamespaceParser() {
|
||||
$file = file_get_contents($this->base . DIRECTORY_SEPARATOR . 'module/classes/ClassI.php');
|
||||
$tokens = token_get_all($file);
|
||||
$parsedTokens = SS_ClassManifest::get_imported_namespace_parser()->findAll($tokens);
|
||||
$parsedTokens = ClassManifest::get_imported_namespace_parser()->findAll($tokens);
|
||||
|
||||
/** @skipUpgrade */
|
||||
$expectedItems = array(
|
||||
array('SilverStripe', '\\', 'Admin', '\\', 'ModelAdmin'),
|
||||
array('SilverStripe', '\\', 'Control', '\\', 'Controller', ' ', 'as', ' ', 'Cont'),
|
||||
array(
|
||||
'SilverStripe', '\\', 'Control', '\\', 'SS_HTTPRequest', ' ', 'as', ' ', 'Request', ',',
|
||||
'SilverStripe', '\\', 'Control', '\\', 'SS_HTTPResponse', ' ', 'as', ' ', 'Response', ',',
|
||||
'SilverStripe', '\\', 'Control', '\\', 'HTTPRequest', ' ', 'as', ' ', 'Request', ',',
|
||||
'SilverStripe', '\\', 'Control', '\\', 'HTTPResponse', ' ', 'as', ' ', 'Response', ',',
|
||||
'SilverStripe', '\\', 'Security', '\\', 'PermissionProvider', ' ', 'as', ' ', 'P',
|
||||
),
|
||||
array('silverstripe', '\\', 'test', '\\', 'ClassA'),
|
||||
@ -69,8 +69,8 @@ class NamespacedClassManifestTest extends SapphireTest {
|
||||
$expectedImports = array(
|
||||
'SilverStripe\\Admin\\ModelAdmin',
|
||||
'Cont' => 'SilverStripe\\Control\\Controller',
|
||||
'Request' => 'SilverStripe\\Control\\SS_HTTPRequest',
|
||||
'Response' => 'SilverStripe\\Control\\SS_HTTPResponse',
|
||||
'Request' => 'SilverStripe\\Control\\HTTPRequest',
|
||||
'Response' => 'SilverStripe\\Control\\HTTPResponse',
|
||||
'P' => 'SilverStripe\\Security\\PermissionProvider',
|
||||
'silverstripe\\test\\ClassA',
|
||||
'\\SilverStripe\\Core\\Object',
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\Manifest\SS_ClassManifest;
|
||||
use SilverStripe\Core\Manifest\ClassManifest;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
/**
|
||||
@ -96,7 +96,7 @@ PHP
|
||||
}
|
||||
|
||||
public function testClassDefParser() {
|
||||
$parser = SS_ClassManifest::get_class_parser();
|
||||
$parser = ClassManifest::get_class_parser();
|
||||
|
||||
$tokens = $this->getTokens();
|
||||
|
||||
@ -126,7 +126,7 @@ PHP
|
||||
}
|
||||
|
||||
public function testNamesapcedClassDefParser() {
|
||||
$parser = SS_ClassManifest::get_namespaced_class_parser();
|
||||
$parser = ClassManifest::get_namespaced_class_parser();
|
||||
|
||||
$tokens = $this->getNamespaceTokens();
|
||||
|
||||
@ -153,7 +153,7 @@ PHP
|
||||
}
|
||||
|
||||
public function testInterfaceDefParser() {
|
||||
$parser = SS_ClassManifest::get_interface_parser();
|
||||
$parser = ClassManifest::get_interface_parser();
|
||||
|
||||
$tokens = $this->getTokens();
|
||||
|
||||
@ -168,7 +168,7 @@ PHP
|
||||
}
|
||||
|
||||
public function testNamespaceDefParser() {
|
||||
$parser = SS_ClassManifest::get_namespace_parser();
|
||||
$parser = ClassManifest::get_namespace_parser();
|
||||
|
||||
$namespacedTokens = $this->getNamespaceTokens();
|
||||
$tokens = $this->getTokens();
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\Admin\ModelAdmin;
|
||||
/** @skipUpgrade */
|
||||
use SilverStripe\Control\Controller as Cont ;
|
||||
/** @skipUpgrade */
|
||||
use SilverStripe\Control\SS_HTTPRequest as Request, SilverStripe\Control\SS_HTTPResponse as Response, SilverStripe\Security\PermissionProvider as P;
|
||||
use SilverStripe\Control\HTTPRequest as Request, SilverStripe\Control\HTTPResponse as Response, SilverStripe\Security\PermissionProvider as P;
|
||||
/** @skipUpgrade */
|
||||
use silverstripe\test\ClassA;
|
||||
/** @skipUpgrade */
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Core\Startup\ErrorControlChain;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
@ -46,7 +46,7 @@ class ErrorControlChainTest_Chain extends ErrorControlChain {
|
||||
function executeInSubprocess($includeStderr = false) {
|
||||
// Get the path to the ErrorControlChain class
|
||||
$erroControlClass = 'SilverStripe\\Core\\Startup\\ErrorControlChain';
|
||||
$classpath = SS_ClassLoader::instance()->getItemPath($erroControlClass);
|
||||
$classpath = ClassLoader::instance()->getItemPath($erroControlClass);
|
||||
$suppression = $this->suppression ? 'true' : 'false';
|
||||
|
||||
// Start building a PHP file that will execute the chain
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\SS_Backtrace;
|
||||
use SilverStripe\Dev\Backtrace;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
/**
|
||||
@ -24,7 +23,7 @@ class BacktraceTest extends SapphireTest {
|
||||
);
|
||||
$this->assertEquals(
|
||||
'MyClass->myFunction(1,more than 20 charact...)',
|
||||
SS_Backtrace::full_func_name($func, true, 20)
|
||||
Backtrace::full_func_name($func, true, 20)
|
||||
);
|
||||
}
|
||||
|
||||
@ -54,22 +53,18 @@ class BacktraceTest extends SapphireTest {
|
||||
'args' => array('myarg' => 'myval')
|
||||
)
|
||||
);
|
||||
$orig = Config::inst()->get('SilverStripe\\Dev\\SS_Backtrace', 'ignore_function_args');
|
||||
Config::inst()->update('SilverStripe\\Dev\\SS_Backtrace', 'ignore_function_args',
|
||||
Backtrace::config()->update('ignore_function_args',
|
||||
array(
|
||||
array('MyClass', 'myIgnoredClassFunction'),
|
||||
'myIgnoredGlobalFunction'
|
||||
)
|
||||
);
|
||||
|
||||
$filtered = SS_Backtrace::filter_backtrace($bt);
|
||||
$filtered = Backtrace::filter_backtrace($bt);
|
||||
|
||||
$this->assertEquals('<filtered>', $filtered[0]['args']['password'], 'Filters global functions');
|
||||
$this->assertEquals('<filtered>', $filtered[1]['args']['password'], 'Filters class functions');
|
||||
$this->assertEquals('myval', $filtered[2]['args']['myarg'], 'Doesnt filter other functions');
|
||||
|
||||
Config::inst()->remove('SilverStripe\\Dev\\SS_Backtrace', 'ignore_function_args');
|
||||
Config::inst()->update('SilverStripe\\Dev\\SS_Backtrace', 'ignore_function_args', $orig);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Assets\SS_FileFinder;
|
||||
use SilverStripe\Assets\FileFinder;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
/**
|
||||
@ -19,7 +19,7 @@ class FileFinderTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testBasicOperation() {
|
||||
$this->assertFinderFinds(new SS_FileFinder(), array(
|
||||
$this->assertFinderFinds(new FileFinder(), array(
|
||||
'file1.txt',
|
||||
'file2.txt',
|
||||
'dir1/dir1file1.txt',
|
||||
@ -33,12 +33,12 @@ class FileFinderTest extends SapphireTest {
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testInvalidOptionThrowsException() {
|
||||
$finder = new SS_FileFinder();
|
||||
$finder = new FileFinder();
|
||||
$finder->setOption('this_doesnt_exist', 'ok');
|
||||
}
|
||||
|
||||
public function testFilenameRegex() {
|
||||
$finder = new SS_FileFinder();
|
||||
$finder = new FileFinder();
|
||||
$finder->setOption('name_regex', '/file2\.txt$/');
|
||||
|
||||
$this->assertFinderFinds(
|
||||
@ -50,7 +50,7 @@ class FileFinderTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testIgnoreFiles() {
|
||||
$finder = new SS_FileFinder();
|
||||
$finder = new FileFinder();
|
||||
$finder->setOption('ignore_files', array('file1.txt', 'dir1file1.txt', 'dir2file1.txt'));
|
||||
|
||||
$this->assertFinderFinds(
|
||||
@ -63,7 +63,7 @@ class FileFinderTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testIgnoreDirs() {
|
||||
$finder = new SS_FileFinder();
|
||||
$finder = new FileFinder();
|
||||
$finder->setOption('ignore_dirs', array('dir2'));
|
||||
|
||||
$this->assertFinderFinds(
|
||||
@ -77,7 +77,7 @@ class FileFinderTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testMinDepth() {
|
||||
$finder = new SS_FileFinder();
|
||||
$finder = new FileFinder();
|
||||
$finder->setOption('min_depth', 2);
|
||||
|
||||
$this->assertFinderFinds(
|
||||
@ -89,7 +89,7 @@ class FileFinderTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testMaxDepth() {
|
||||
$finder = new SS_FileFinder();
|
||||
$finder = new FileFinder();
|
||||
$finder->setOption('max_depth', 1);
|
||||
|
||||
$this->assertFinderFinds(
|
||||
@ -102,7 +102,7 @@ class FileFinderTest extends SapphireTest {
|
||||
'The finder respects the max depth setting.');
|
||||
}
|
||||
|
||||
public function assertFinderFinds(SS_FileFinder $finder, $expect, $message = null) {
|
||||
public function assertFinderFinds(FileFinder $finder, $expect, $message = null) {
|
||||
$found = $finder->find($this->base);
|
||||
|
||||
foreach ($expect as $k => $file) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
use SilverStripe\Assets\FileNameFilter;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\View\Parsers\SS_Transliterator;
|
||||
use SilverStripe\View\Parsers\Transliterator;
|
||||
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ class FileNameFilterTest extends SapphireTest {
|
||||
public function testFilterWithTransliterator() {
|
||||
$name = 'Brötchen für allë-mit_Unterstrich!.jpg';
|
||||
$filter = new FileNameFilter();
|
||||
$filter->setTransliterator(new SS_Transliterator());
|
||||
$filter->setTransliterator(new Transliterator());
|
||||
$this->assertEquals(
|
||||
'Broetchen-fuer-alle-mit-Unterstrich.jpg',
|
||||
$filter->filter($name)
|
||||
@ -59,7 +59,7 @@ class FileNameFilterTest extends SapphireTest {
|
||||
public function testFilterWithEmptyString() {
|
||||
$name = 'ö ö ö.jpg';
|
||||
$filter = new FileNameFilter();
|
||||
$filter->setTransliterator(new SS_Transliterator());
|
||||
$filter->setTransliterator(new Transliterator());
|
||||
$result = $filter->filter($name);
|
||||
$this->assertFalse(
|
||||
empty($result)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Assets\GDBackend;
|
||||
use SilverStripe\Core\SS_Cache;
|
||||
use SilverStripe\Core\Cache;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
@ -178,7 +178,7 @@ class GDTest extends SapphireTest {
|
||||
$gd->loadFrom($fullPath);
|
||||
|
||||
// Cache should refer to this file
|
||||
$cache = SS_Cache::factory('GDBackend_Manipulations');
|
||||
$cache = Cache::factory('GDBackend_Manipulations');
|
||||
$key = sha1(implode('|', array($fullPath, filemtime($fullPath))));
|
||||
$data = $cache->load($key);
|
||||
$this->assertEquals('1', $data);
|
||||
|
@ -7,7 +7,7 @@ use SilverStripe\Assets\Filesystem;
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
|
||||
|
||||
|
||||
@ -195,9 +195,9 @@ class ProtectedFileControllerTest extends FunctionalTest {
|
||||
*
|
||||
* @param int $code HTTP code
|
||||
* @param string $body Body expected for 200 responses
|
||||
* @param SS_HTTPResponse $response
|
||||
* @param HTTPResponse $response
|
||||
*/
|
||||
protected function assertResponseEquals($code, $body, SS_HTTPResponse $response) {
|
||||
protected function assertResponseEquals($code, $body, HTTPResponse $response) {
|
||||
$this->assertEquals($code, $response->getStatusCode());
|
||||
if($code === 200) {
|
||||
$this->assertFalse($response->isError());
|
||||
|
@ -9,7 +9,7 @@ use SilverStripe\Dev\CSSContentParser;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\Form;
|
||||
@ -658,7 +658,7 @@ class FormTest extends FunctionalTest {
|
||||
|
||||
$controller = new FormTest_Controller();
|
||||
$form = $controller->Form();
|
||||
$request = new SS_HTTPRequest('POST', 'FormTest_Controller/Form', array(), array(
|
||||
$request = new HTTPRequest('POST', 'FormTest_Controller/Form', array(), array(
|
||||
'Email' => 'test@test.com',
|
||||
'SomeRequiredField' => 1,
|
||||
'action_doSubmit' => 1
|
||||
@ -676,7 +676,7 @@ class FormTest extends FunctionalTest {
|
||||
new FieldList()
|
||||
);
|
||||
$form->disableSecurityToken();
|
||||
$request = new SS_HTTPRequest('POST', 'FormTest_Controller/Form', array(), array(
|
||||
$request = new HTTPRequest('POST', 'FormTest_Controller/Form', array(), array(
|
||||
'action_doSubmit' => 1
|
||||
));
|
||||
|
||||
@ -727,7 +727,7 @@ class FormTest extends FunctionalTest {
|
||||
|
||||
function testMessageEscapeHtml() {
|
||||
$form = $this->getStubForm();
|
||||
$form->getController()->handleRequest(new SS_HTTPRequest('GET', '/'), DataModel::inst()); // stub out request
|
||||
$form->getController()->handleRequest(new HTTPRequest('GET', '/'), DataModel::inst()); // stub out request
|
||||
$form->sessionMessage('<em>Escaped HTML</em>', 'good', true);
|
||||
$parser = new CSSContentParser($form->forTemplate());
|
||||
$messageEls = $parser->getBySelector('.message');
|
||||
@ -737,7 +737,7 @@ class FormTest extends FunctionalTest {
|
||||
);
|
||||
|
||||
$form = $this->getStubForm();
|
||||
$form->getController()->handleRequest(new SS_HTTPRequest('GET', '/'), DataModel::inst()); // stub out request
|
||||
$form->getController()->handleRequest(new HTTPRequest('GET', '/'), DataModel::inst()); // stub out request
|
||||
$form->sessionMessage('<em>Unescaped HTML</em>', 'good', false);
|
||||
$parser = new CSSContentParser($form->forTemplate());
|
||||
$messageEls = $parser->getBySelector('.message');
|
||||
@ -749,7 +749,7 @@ class FormTest extends FunctionalTest {
|
||||
|
||||
function testFieldMessageEscapeHtml() {
|
||||
$form = $this->getStubForm();
|
||||
$form->getController()->handleRequest(new SS_HTTPRequest('GET', '/'), DataModel::inst()); // stub out request
|
||||
$form->getController()->handleRequest(new HTTPRequest('GET', '/'), DataModel::inst()); // stub out request
|
||||
$form->addErrorMessage('key1', '<em>Escaped HTML</em>', 'good', true);
|
||||
$form->setupFormErrors();
|
||||
$parser = new CSSContentParser($result = $form->forTemplate());
|
||||
@ -760,7 +760,7 @@ class FormTest extends FunctionalTest {
|
||||
);
|
||||
|
||||
$form = $this->getStubForm();
|
||||
$form->getController()->handleRequest(new SS_HTTPRequest('GET', '/'), DataModel::inst()); // stub out request
|
||||
$form->getController()->handleRequest(new HTTPRequest('GET', '/'), DataModel::inst()); // stub out request
|
||||
$form->addErrorMessage('key1', '<em>Unescaped HTML</em>', 'good', false);
|
||||
$form->setupFormErrors();
|
||||
$parser = new CSSContentParser($form->forTemplate());
|
||||
|
@ -366,7 +366,7 @@ class GridFieldTest extends SapphireTest {
|
||||
// $id = 'testGridStateActionField';
|
||||
// Session::set($id, array('grid'=>'', 'actionName'=>'jump'));
|
||||
// $form = new Form(new Controller(), 'mockform', new FieldList(array($obj)), new FieldList());
|
||||
// $request = new SS_HTTPRequest('POST', 'url');
|
||||
// $request = new HTTPRequest('POST', 'url');
|
||||
// $obj->gridFieldAlterAction(array('StateID'=>$id), $form, $request);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Assets\Filesystem;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Dev\CSSContentParser;
|
||||
@ -170,7 +170,7 @@ EOS
|
||||
$page->write();
|
||||
$this->useDraftSite(true);
|
||||
|
||||
$request = new SS_HTTPRequest('GET', '/', array(
|
||||
$request = new HTTPRequest('GET', '/', array(
|
||||
'PageID' => $page->ID,
|
||||
));
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Assets\Image;
|
||||
use SilverStripe\Control\SS_HTTPResponse_Exception;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField_Toolbar;
|
||||
|
||||
@ -69,7 +69,7 @@ class HTMLEditorFieldToolbarTest extends SapphireTest {
|
||||
$this->assertEquals($url, 'http://example.com/test.pdf');
|
||||
}
|
||||
|
||||
/** @expectedException SilverStripe\Control\SS_HTTPResponse_Exception */
|
||||
/** @expectedException SilverStripe\Control\HTTPResponse_Exception */
|
||||
public function testInvalidScheme() {
|
||||
list($file, $url) = $this->getToolbar()->viewfile_getRemoteFileByURL('nosuchscheme://example.com/test.pdf');
|
||||
}
|
||||
@ -79,7 +79,7 @@ class HTMLEditorFieldToolbarTest extends SapphireTest {
|
||||
$this->assertEquals($url, 'http://example.com/test.pdf');
|
||||
}
|
||||
|
||||
/** @expectedException SilverStripe\Control\SS_HTTPResponse_Exception */
|
||||
/** @expectedException SilverStripe\Control\HTTPResponse_Exception */
|
||||
public function testInvalidDomain() {
|
||||
list($file, $url) = $this->getToolbar()->viewfile_getRemoteFileByURL('http://evil.com/test.pdf');
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use SilverStripe\Dev\CSSContentParser;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Forms\TreeDropdownField;
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ class TreeDropdownFieldTest extends SapphireTest {
|
||||
$field = new TreeDropdownField('TestTree', 'Test tree', 'SilverStripe\\Assets\\Folder');
|
||||
|
||||
// case insensitive search against keyword 'sub' for folders
|
||||
$request = new SS_HTTPRequest('GET','url',array('search'=>'sub'));
|
||||
$request = new HTTPRequest('GET','url',array('search'=>'sub'));
|
||||
$tree = $field->tree($request);
|
||||
|
||||
$folder1 = $this->objFromFixture('SilverStripe\\Assets\\Folder','folder1');
|
||||
@ -56,7 +56,7 @@ class TreeDropdownFieldTest extends SapphireTest {
|
||||
$field = new TreeDropdownField('TestTree', 'Test tree', 'SilverStripe\\Assets\\File');
|
||||
|
||||
// case insensitive search against keyword 'sub' for files
|
||||
$request = new SS_HTTPRequest('GET','url',array('search'=>'sub'));
|
||||
$request = new HTTPRequest('GET','url',array('search'=>'sub'));
|
||||
$tree = $field->tree($request);
|
||||
|
||||
$parser = new CSSContentParser($tree);
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\Dev\CSSContentParser;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\Form;
|
||||
@ -66,7 +66,7 @@ class GridFieldDeleteActionTest extends SapphireTest {
|
||||
public function testActionsRequireCSRF() {
|
||||
$this->logInWithPermission('ADMIN');
|
||||
$this->setExpectedException(
|
||||
'SilverStripe\\Control\\SS_HTTPResponse_Exception',
|
||||
'SilverStripe\\Control\\HTTPResponse_Exception',
|
||||
_t("Form.CSRF_FAILED_MESSAGE",
|
||||
"There seems to have been a technical problem. Please click the back button, ".
|
||||
"refresh your browser, and try again."
|
||||
@ -74,7 +74,7 @@ class GridFieldDeleteActionTest extends SapphireTest {
|
||||
400
|
||||
);
|
||||
$stateID = 'testGridStateActionField';
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'url',
|
||||
array(),
|
||||
@ -102,7 +102,7 @@ class GridFieldDeleteActionTest extends SapphireTest {
|
||||
)
|
||||
);
|
||||
$token = SecurityToken::inst();
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'url',
|
||||
array(),
|
||||
@ -130,7 +130,7 @@ class GridFieldDeleteActionTest extends SapphireTest {
|
||||
)
|
||||
);
|
||||
$token = SecurityToken::inst();
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'url',
|
||||
array(),
|
||||
@ -163,7 +163,7 @@ class GridFieldDeleteActionTest extends SapphireTest {
|
||||
)
|
||||
);
|
||||
$token = SecurityToken::inst();
|
||||
$request = new SS_HTTPRequest(
|
||||
$request = new HTTPRequest(
|
||||
'POST',
|
||||
'url',
|
||||
array(),
|
||||
|
@ -15,9 +15,6 @@ use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\FormAction;
|
||||
use SilverStripe\Forms\RequiredFields;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @package framework
|
||||
* @subpackage tests
|
||||
@ -360,7 +357,7 @@ class AssetFieldTest extends FunctionalTest {
|
||||
*
|
||||
* @param string $fileField Name of the field to mock upload for
|
||||
* @param array $tmpFileName Name of temporary file to upload
|
||||
* @return SS_HTTPResponse form response
|
||||
* @return HTTPResponse form response
|
||||
*/
|
||||
protected function mockFileUpload($fileField, $tmpFileName) {
|
||||
$upload = $this->getUploadFile($tmpFileName);
|
||||
|
@ -947,7 +947,7 @@ class UploadFieldTest extends FunctionalTest {
|
||||
*
|
||||
* @param string $fileField Name of the field to mock upload for
|
||||
* @param array $tmpFileName Name of temporary file to upload
|
||||
* @return SS_HTTPResponse form response
|
||||
* @return HTTPResponse form response
|
||||
*/
|
||||
protected function mockFileUpload($fileField, $tmpFileName) {
|
||||
$upload = $this->getUploadFile($tmpFileName);
|
||||
@ -969,7 +969,7 @@ class UploadFieldTest extends FunctionalTest {
|
||||
*
|
||||
* @param string $fileField Name of the field
|
||||
* @param integer $fileID ID of the file to delete
|
||||
* @return SS_HTTPResponse form response
|
||||
* @return HTTPResponse form response
|
||||
*/
|
||||
protected function mockFileEditForm($fileField, $fileID) {
|
||||
return $this->get(
|
||||
@ -983,7 +983,7 @@ class UploadFieldTest extends FunctionalTest {
|
||||
* @param string $fileField Name of the field
|
||||
* @param integer $fileID ID of the file to delete
|
||||
* @param array $fields Fields to update
|
||||
* @return SS_HTTPResponse form response
|
||||
* @return HTTPResponse form response
|
||||
*/
|
||||
protected function mockFileEdit($fileField, $fileID, $fields = array()) {
|
||||
return $this->post(
|
||||
@ -997,7 +997,7 @@ class UploadFieldTest extends FunctionalTest {
|
||||
*
|
||||
* @param string $fileField Name of the field
|
||||
* @param integer $fileID ID of the file to delete
|
||||
* @return SS_HTTPResponse form response
|
||||
* @return HTTPResponse form response
|
||||
*/
|
||||
protected function mockFileDelete($fileField, $fileID) {
|
||||
return $this->post(
|
||||
|
@ -4,8 +4,8 @@ use SilverStripe\Assets\Filesystem;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\Core\Manifest\SS_ClassManifest;
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ClassManifest;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\i18n\i18n;
|
||||
@ -437,8 +437,8 @@ class i18nTest extends SapphireTest {
|
||||
public function testIncludeByLocale() {
|
||||
// Looping through modules, so we can test the translation autoloading
|
||||
// Load non-exclusive to retain core class autoloading
|
||||
$classManifest = new SS_ClassManifest($this->alternateBasePath, true, true, false);
|
||||
SS_ClassLoader::instance()->pushManifest($classManifest);
|
||||
$classManifest = new ClassManifest($this->alternateBasePath, true, true, false);
|
||||
ClassLoader::instance()->pushManifest($classManifest);
|
||||
|
||||
$adapter = i18n::get_translator('core')->getAdapter();
|
||||
$this->assertTrue($adapter->isAvailable('en'));
|
||||
@ -466,12 +466,12 @@ class i18nTest extends SapphireTest {
|
||||
'High Module Priority (de)'
|
||||
);
|
||||
|
||||
SS_ClassLoader::instance()->popManifest();
|
||||
ClassLoader::instance()->popManifest();
|
||||
}
|
||||
|
||||
public function testIncludeByLocaleWithoutFallbackLanguage() {
|
||||
$classManifest = new SS_ClassManifest($this->alternateBasePath, true, true, false);
|
||||
SS_ClassLoader::instance()->pushManifest($classManifest);
|
||||
$classManifest = new ClassManifest($this->alternateBasePath, true, true, false);
|
||||
ClassLoader::instance()->pushManifest($classManifest);
|
||||
|
||||
$adapter = i18n::get_translator('core')->getAdapter();
|
||||
$this->assertTrue($adapter->isAvailable('en'));
|
||||
@ -490,7 +490,7 @@ class i18nTest extends SapphireTest {
|
||||
$this->assertTrue($adapter->isAvailable('mi_NZ'));
|
||||
$this->assertTrue($adapter->isTranslated('i18nTestModule.ENTITY', null, 'mi_NZ'), 'Includes module files');
|
||||
|
||||
SS_ClassLoader::instance()->popManifest();
|
||||
ClassLoader::instance()->popManifest();
|
||||
}
|
||||
|
||||
public function testRegisterTranslator() {
|
||||
@ -513,8 +513,8 @@ class i18nTest extends SapphireTest {
|
||||
public function testMultipleTranslators() {
|
||||
// Looping through modules, so we can test the translation autoloading
|
||||
// Load non-exclusive to retain core class autoloading
|
||||
$classManifest = new SS_ClassManifest($this->alternateBasePath, true, true, false);
|
||||
SS_ClassLoader::instance()->pushManifest($classManifest);
|
||||
$classManifest = new ClassManifest($this->alternateBasePath, true, true, false);
|
||||
ClassLoader::instance()->pushManifest($classManifest);
|
||||
|
||||
// Changed manifest, so we also need to unset all previously collected messages.
|
||||
// The easiest way to do this it to register a new adapter.
|
||||
@ -584,7 +584,7 @@ class i18nTest extends SapphireTest {
|
||||
i18n::unregister_translator('othercustom_lower_prio');
|
||||
i18n::unregister_translator('othercustom_higher_prio');
|
||||
|
||||
SS_ClassLoader::instance()->popManifest();
|
||||
ClassLoader::instance()->popManifest();
|
||||
}
|
||||
|
||||
public function testGetLanguageName() {
|
||||
|
@ -3,8 +3,8 @@
|
||||
use SilverStripe\Assets\Filesystem;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Manifest\SS_ClassManifest;
|
||||
use SilverStripe\Core\Manifest\SS_ClassLoader;
|
||||
use SilverStripe\Core\Manifest\ClassManifest;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\i18n\i18n;
|
||||
@ -43,7 +43,7 @@ class i18nTextCollectorTest extends SapphireTest {
|
||||
|
||||
// Push a class and template loader running from the fake webroot onto
|
||||
// the stack.
|
||||
$this->manifest = new SS_ClassManifest(
|
||||
$this->manifest = new ClassManifest(
|
||||
$this->alternateBasePath, false, true, false
|
||||
);
|
||||
|
||||
@ -55,8 +55,8 @@ class i18nTextCollectorTest extends SapphireTest {
|
||||
public function tearDown() {
|
||||
ThemeResourceLoader::set_instance($this->_oldLoader);
|
||||
// Pop if added during testing
|
||||
if(SS_ClassLoader::instance()->getManifest() === $this->manifest) {
|
||||
SS_ClassLoader::instance()->popManifest();
|
||||
if(ClassLoader::instance()->getManifest() === $this->manifest) {
|
||||
ClassLoader::instance()->popManifest();
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
@ -649,7 +649,7 @@ YAML;
|
||||
* Test that duplicate keys are resolved to the appropriate modules
|
||||
*/
|
||||
public function testResolveDuplicates() {
|
||||
SS_ClassLoader::instance()->pushManifest($this->manifest);
|
||||
ClassLoader::instance()->pushManifest($this->manifest);
|
||||
$collector = new i18nTextCollectorTest_Collector();
|
||||
|
||||
// Dummy data as collected
|
||||
@ -712,7 +712,7 @@ YAML;
|
||||
* Test ability for textcollector to detect modules
|
||||
*/
|
||||
public function testModuleDetection() {
|
||||
SS_ClassLoader::instance()->pushManifest($this->manifest);
|
||||
ClassLoader::instance()->pushManifest($this->manifest);
|
||||
$collector = new i18nTextCollectorTest_Collector();
|
||||
$modules = $collector->getModules_Test($this->alternateBasePath);
|
||||
$this->assertEquals(
|
||||
|
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\View\Parsers\SS_HTML4Value;
|
||||
use SilverStripe\View\Parsers\HTML4Value;
|
||||
|
||||
/**
|
||||
* @package framework
|
||||
* @subpackage tests
|
||||
*/
|
||||
class SS_HTML4ValueTest extends SapphireTest {
|
||||
class HTML4ValueTest extends SapphireTest {
|
||||
public function testInvalidHTMLSaving() {
|
||||
$value = new SS_HTML4Value();
|
||||
$value = new HTML4Value();
|
||||
|
||||
$invalid = array (
|
||||
'<p>Enclosed Value</p></p>' => '<p>Enclosed Value</p>',
|
||||
@ -26,14 +26,14 @@ class SS_HTML4ValueTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testUtf8Saving() {
|
||||
$value = new SS_HTML4Value();
|
||||
$value = new HTML4Value();
|
||||
|
||||
$value->setContent('<p>ö ß ā い 家</p>');
|
||||
$this->assertEquals('<p>ö ß ā い 家</p>', $value->getContent());
|
||||
}
|
||||
|
||||
public function testInvalidHTMLTagNames() {
|
||||
$value = new SS_HTML4Value();
|
||||
$value = new HTML4Value();
|
||||
|
||||
$invalid = array(
|
||||
'<p><div><a href="test-link"></p></div>',
|
||||
@ -52,7 +52,7 @@ class SS_HTML4ValueTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testMixedNewlines() {
|
||||
$value = new SS_HTML4Value();
|
||||
$value = new HTML4Value();
|
||||
|
||||
$value->setContent("<p>paragraph</p>\n<ul><li>1</li>\r\n</ul>");
|
||||
$this->assertEquals(
|
||||
@ -63,7 +63,7 @@ class SS_HTML4ValueTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testAttributeEscaping() {
|
||||
$value = new SS_HTML4Value();
|
||||
$value = new HTML4Value();
|
||||
|
||||
$value->setContent('<a href="[]"></a>');
|
||||
$this->assertEquals('<a href="[]"></a>', $value->getContent(), "'[' character isn't escaped");
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\SS_Filterable;
|
||||
use SilverStripe\ORM\Filterable;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\View\ArrayData;
|
||||
|
||||
@ -225,7 +225,7 @@ class ArrayListTest extends SapphireTest {
|
||||
$map = $list->map('ID', 'Name');
|
||||
// Items added after calling map should not be included retroactively
|
||||
$list->add(array('ID' => 7, 'Name' => 'Andrew'));
|
||||
$this->assertInstanceOf('SilverStripe\\ORM\\SS_Map', $map);
|
||||
$this->assertInstanceOf('SilverStripe\\ORM\\Map', $map);
|
||||
$this->assertEquals(array(
|
||||
1 => 'Steve',
|
||||
3 => 'Bob',
|
||||
@ -686,7 +686,7 @@ class ArrayListTest extends SapphireTest {
|
||||
|
||||
$this->assertEquals(2, $list->count());
|
||||
$this->assertEquals($expected, $list->toArray(), 'List should only contain Steve and Clair');
|
||||
$this->assertTrue($list instanceof SS_Filterable, 'The List should be of type SS_Filterable');
|
||||
$this->assertTrue($list instanceof Filterable, 'The List should be of type SS_Filterable');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\SS_Filterable;
|
||||
use SilverStripe\ORM\Filterable;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
|
||||
@ -1086,7 +1086,7 @@ class DataListTest extends SapphireTest {
|
||||
|
||||
$this->assertEquals(2, $list->count());
|
||||
$this->assertEquals($expected, $result, 'List should only contain comments from Team 1 (Joe and Bob)');
|
||||
$this->assertTrue($list instanceof SS_Filterable, 'The List should be of type SS_Filterable');
|
||||
$this->assertTrue($list instanceof Filterable, 'The List should be of type SS_Filterable');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1281,6 +1281,7 @@ class DataObjectTest extends SapphireTest {
|
||||
|
||||
// Test invalid classes fail
|
||||
$this->setExpectedException('InvalidArgumentException', "Controller is not a valid subclass of DataObject");
|
||||
/** @skipUpgrade */
|
||||
$dataObject->newClassInstance('Controller');
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\SS_Cache;
|
||||
use SilverStripe\Core\Cache;
|
||||
|
||||
class GDImageTest extends ImageTest {
|
||||
|
||||
@ -22,7 +22,7 @@ class GDImageTest extends ImageTest {
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$cache = SS_Cache::factory('GDBackend_Manipulations');
|
||||
$cache = Cache::factory('GDBackend_Manipulations');
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\ORM\SS_Map;
|
||||
use SilverStripe\ORM\Map;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
@ -9,7 +9,7 @@ use SilverStripe\Dev\SapphireTest;
|
||||
* @package framework
|
||||
* @subpackage tests
|
||||
*/
|
||||
class SS_MapTest extends SapphireTest {
|
||||
class MapTest extends SapphireTest {
|
||||
|
||||
// Borrow the model from DataObjectTest
|
||||
protected static $fixture_file = 'DataObjectTest.yml';
|
||||
@ -22,7 +22,7 @@ class SS_MapTest extends SapphireTest {
|
||||
|
||||
public function testValues() {
|
||||
$list = DataObjectTest_TeamComment::get()->sort('Name');
|
||||
$map = new SS_Map($list, 'Name', 'Comment');
|
||||
$map = new Map($list, 'Name', 'Comment');
|
||||
|
||||
$this->assertEquals(array(
|
||||
'This is a team comment by Bob',
|
||||
@ -40,14 +40,14 @@ class SS_MapTest extends SapphireTest {
|
||||
'Item'
|
||||
), $map->values());
|
||||
|
||||
$map = new SS_Map(new ArrayList());
|
||||
$map = new Map(new ArrayList());
|
||||
$map->push('Push', 'Pushed value');
|
||||
|
||||
$this->assertEquals(array(
|
||||
'Pushed value'
|
||||
), $map->values());
|
||||
|
||||
$map = new SS_Map(new ArrayList());
|
||||
$map = new Map(new ArrayList());
|
||||
$map->unshift('Unshift', 'Unshift item');
|
||||
|
||||
$this->assertEquals(array(
|
||||
@ -58,14 +58,14 @@ class SS_MapTest extends SapphireTest {
|
||||
|
||||
public function testArrayAccess() {
|
||||
$list = DataObjectTest_TeamComment::get();
|
||||
$map = new SS_Map($list, 'Name', 'Comment');
|
||||
$map = new Map($list, 'Name', 'Comment');
|
||||
$this->assertEquals('This is a team comment by Joe', $map['Joe']);
|
||||
$this->assertNull($map['DoesntExist']);
|
||||
}
|
||||
|
||||
public function testIteration() {
|
||||
$list = DataObjectTest_TeamComment::get()->sort('ID');
|
||||
$map = new SS_Map($list, 'Name', 'Comment');
|
||||
$map = new Map($list, 'Name', 'Comment');
|
||||
$text = "";
|
||||
foreach($map as $k => $v) {
|
||||
$text .= "$k: $v\n";
|
||||
@ -77,13 +77,13 @@ class SS_MapTest extends SapphireTest {
|
||||
|
||||
public function testDefaultConfigIsIDAndTitle() {
|
||||
$list = DataObjectTest_Team::get();
|
||||
$map = new SS_Map($list);
|
||||
$map = new Map($list);
|
||||
$this->assertEquals('Team 1', $map[$this->idFromFixture('DataObjectTest_Team', 'team1')]);
|
||||
}
|
||||
|
||||
public function testSetKeyFieldAndValueField() {
|
||||
$list = DataObjectTest_TeamComment::get();
|
||||
$map = new SS_Map($list);
|
||||
$map = new Map($list);
|
||||
$map->setKeyField('Name');
|
||||
$map->setValueField('Comment');
|
||||
$this->assertEquals('This is a team comment by Joe', $map['Joe']);
|
||||
@ -91,7 +91,7 @@ class SS_MapTest extends SapphireTest {
|
||||
|
||||
public function testToArray() {
|
||||
$list = DataObjectTest_TeamComment::get();
|
||||
$map = new SS_Map($list, 'Name', 'Comment');
|
||||
$map = new Map($list, 'Name', 'Comment');
|
||||
$this->assertEquals(array("Joe" => "This is a team comment by Joe",
|
||||
"Bob" => "This is a team comment by Bob",
|
||||
"Phil" => "Phil is a unique guy, and comments on team2"), $map->toArray());
|
||||
@ -99,7 +99,7 @@ class SS_MapTest extends SapphireTest {
|
||||
|
||||
public function testKeys() {
|
||||
$list = DataObjectTest_TeamComment::get()->sort('Name');
|
||||
$map = new SS_Map($list, 'Name', 'Comment');
|
||||
$map = new Map($list, 'Name', 'Comment');
|
||||
$this->assertEquals(array(
|
||||
'Bob',
|
||||
'Joe',
|
||||
@ -125,14 +125,14 @@ class SS_MapTest extends SapphireTest {
|
||||
'Push'
|
||||
), $map->keys());
|
||||
|
||||
$map = new SS_Map(new ArrayList());
|
||||
$map = new Map(new ArrayList());
|
||||
$map->push('Push', 'Item');
|
||||
|
||||
$this->assertEquals(array(
|
||||
'Push'
|
||||
), $map->keys());
|
||||
|
||||
$map = new SS_Map(new ArrayList());
|
||||
$map = new Map(new ArrayList());
|
||||
$map->unshift('Unshift', 'Item');
|
||||
|
||||
$this->assertEquals(array(
|
||||
@ -142,7 +142,7 @@ class SS_MapTest extends SapphireTest {
|
||||
|
||||
public function testMethodAsValueField() {
|
||||
$list = DataObjectTest_Team::get()->sort('Title');
|
||||
$map = new SS_Map($list, 'ID', 'MyTitle');
|
||||
$map = new Map($list, 'ID', 'MyTitle');
|
||||
$this->assertEquals(array(
|
||||
'Team Subteam 1',
|
||||
'Team Subteam 2',
|
||||
@ -155,7 +155,7 @@ class SS_MapTest extends SapphireTest {
|
||||
|
||||
public function testUnshift() {
|
||||
$list = DataObjectTest_TeamComment::get();
|
||||
$map = new SS_Map($list, 'Name', 'Comment');
|
||||
$map = new Map($list, 'Name', 'Comment');
|
||||
|
||||
$map->unshift(-1, '(All)');
|
||||
|
||||
@ -204,7 +204,7 @@ class SS_MapTest extends SapphireTest {
|
||||
|
||||
public function testPush() {
|
||||
$list = DataObjectTest_TeamComment::get();
|
||||
$map = new SS_Map($list, 'Name', 'Comment');
|
||||
$map = new Map($list, 'Name', 'Comment');
|
||||
|
||||
$map->push(1, '(All)');
|
||||
|
||||
@ -218,7 +218,7 @@ class SS_MapTest extends SapphireTest {
|
||||
|
||||
public function testCount() {
|
||||
$list = DataObjectTest_TeamComment::get();
|
||||
$map = new SS_Map($list, 'Name', 'Comment');
|
||||
$map = new Map($list, 'Name', 'Comment');
|
||||
|
||||
$this->assertEquals(3, $map->count());
|
||||
|
||||
@ -229,7 +229,7 @@ class SS_MapTest extends SapphireTest {
|
||||
$map->unshift(2, 'Item shifted');
|
||||
$this->assertEquals(5, $map->count());
|
||||
|
||||
$map = new SS_Map(new ArrayList());
|
||||
$map = new Map(new ArrayList());
|
||||
$map->unshift('1', 'shifted');
|
||||
|
||||
$this->assertEquals(1, $map->count());
|
||||
@ -240,7 +240,7 @@ class SS_MapTest extends SapphireTest {
|
||||
|
||||
public function testIterationWithUnshift() {
|
||||
$list = DataObjectTest_TeamComment::get()->sort('ID');
|
||||
$map = new SS_Map($list, 'Name', 'Comment');
|
||||
$map = new Map($list, 'Name', 'Comment');
|
||||
$map->unshift(1, 'Unshifted');
|
||||
|
||||
$text = "";
|
||||
@ -258,7 +258,7 @@ class SS_MapTest extends SapphireTest {
|
||||
|
||||
public function testIterationWithPush() {
|
||||
$list = DataObjectTest_TeamComment::get()->sort('ID');
|
||||
$map = new SS_Map($list, 'Name', 'Comment');
|
||||
$map = new Map($list, 'Name', 'Comment');
|
||||
$map->push(1, 'Pushed');
|
||||
|
||||
$text = "";
|
||||
@ -275,7 +275,7 @@ class SS_MapTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testIterationWithEmptyListUnshifted() {
|
||||
$map = new SS_Map(new ArrayList());
|
||||
$map = new Map(new ArrayList());
|
||||
$map->unshift('1', 'unshifted');
|
||||
|
||||
$text = "";
|
||||
@ -288,7 +288,7 @@ class SS_MapTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testIterationWithEmptyListPushed() {
|
||||
$map = new SS_Map(new ArrayList());
|
||||
$map = new Map(new ArrayList());
|
||||
$map->push('1', 'pushed');
|
||||
|
||||
$text = "";
|
||||
|
@ -866,7 +866,7 @@ class VersionedTest extends SapphireTest {
|
||||
* Test that stage parameter is blocked by non-administrative users
|
||||
*/
|
||||
public function testReadingModeSecurity() {
|
||||
$this->setExpectedException('SilverStripe\\Control\\SS_HTTPResponse_Exception');
|
||||
$this->setExpectedException('SilverStripe\\Control\\HTTPResponse_Exception');
|
||||
$session = Injector::inst()->create('SilverStripe\\Control\\Session', array());
|
||||
$result = Director::test('/?stage=Stage', null, $session);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\Controller;
|
||||
@ -107,7 +107,7 @@ class SecurityTest extends FunctionalTest {
|
||||
|
||||
// Controller that doesn't attempt redirections
|
||||
$controller = new SecurityTest_NullController();
|
||||
$controller->setResponse(new SS_HTTPResponse());
|
||||
$controller->setResponse(new HTTPResponse());
|
||||
|
||||
Security::permissionFailure($controller, array('default' => 'Oops, not allowed'));
|
||||
$this->assertEquals('Oops, not allowed', Session::get('Security.Message.message'));
|
||||
@ -148,12 +148,12 @@ class SecurityTest extends FunctionalTest {
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $limit Max number of requests
|
||||
* @return SS_HTTPResponse
|
||||
* @return HTTPResponse
|
||||
*/
|
||||
protected function getRecursive($url, $limit = 10) {
|
||||
$this->cssParser = null;
|
||||
$response = $this->mainSession->get($url);
|
||||
while(--$limit > 0 && $response instanceof SS_HTTPResponse && $response->getHeader('Location')) {
|
||||
while(--$limit > 0 && $response instanceof HTTPResponse && $response->getHeader('Location')) {
|
||||
$response = $this->mainSession->followRedirection();
|
||||
}
|
||||
return $response;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use SilverStripe\Security\SecurityToken;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Control\SS_HTTPRequest;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
|
||||
|
||||
@ -87,28 +87,28 @@ class SecurityTokenTest extends SapphireTest {
|
||||
$n = $t->getName();
|
||||
|
||||
$t->setValue(null);
|
||||
$r = new SS_HTTPRequest('GET', 'dummy', array($n => 'invalidtoken'));
|
||||
$r = new HTTPRequest('GET', 'dummy', array($n => 'invalidtoken'));
|
||||
$this->assertFalse($t->checkRequest($r), 'Any token is invalid if no token is stored');
|
||||
|
||||
$t->setValue(null);
|
||||
$r = new SS_HTTPRequest('GET', 'dummy', array($n => null));
|
||||
$r = new HTTPRequest('GET', 'dummy', array($n => null));
|
||||
$this->assertFalse($t->checkRequest($r), 'NULL token is invalid if no token is stored');
|
||||
|
||||
$t->setValue('mytoken');
|
||||
$r = new SS_HTTPRequest('GET', 'dummy', array($n => 'invalidtoken'));
|
||||
$r = new HTTPRequest('GET', 'dummy', array($n => 'invalidtoken'));
|
||||
$this->assertFalse($t->checkRequest($r), 'Invalid token returns false');
|
||||
|
||||
$t->setValue('mytoken');
|
||||
$r = new SS_HTTPRequest('GET', 'dummy', array($n => 'mytoken'));
|
||||
$r = new HTTPRequest('GET', 'dummy', array($n => 'mytoken'));
|
||||
$this->assertTrue($t->checkRequest($r), 'Valid token returns true');
|
||||
|
||||
$t->setValue('mytoken');
|
||||
$r = new SS_HTTPRequest('GET', 'dummy');
|
||||
$r = new HTTPRequest('GET', 'dummy');
|
||||
$r->addHeader('X-Securityid', 'mytoken');
|
||||
$this->assertTrue($t->checkRequest($r), 'Valid token returns true');
|
||||
|
||||
$t->setValue('mytoken');
|
||||
$r = new SS_HTTPRequest('GET', 'dummy');
|
||||
$r = new HTTPRequest('GET', 'dummy');
|
||||
$r->addHeader('X-Securityid', 'wrongtoken');
|
||||
$this->assertFalse($t->checkRequest($r), 'Valid token returns true');
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Control\ContentNegotiator;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ class ContentNegotiatorTest extends SapphireTest {
|
||||
// Check that the content negotiator converts to the equally legal formats
|
||||
$negotiator = new ContentNegotiator();
|
||||
|
||||
$response = new SS_HTTPResponse($this->render($tmpl1));
|
||||
$response = new HTTPResponse($this->render($tmpl1));
|
||||
$negotiator->xhtml($response);
|
||||
|
||||
////////////////////////
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\Versioning\Versioned;
|
||||
use SilverStripe\Core\SS_Cache;
|
||||
use SilverStripe\Core\Cache;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Control\Director;
|
||||
@ -61,8 +61,8 @@ class SSViewerCacheBlockTest extends SapphireTest {
|
||||
protected function _reset($cacheOn = true) {
|
||||
$this->data = new SSViewerCacheBlockTest_Model();
|
||||
|
||||
SS_Cache::factory('cacheblock')->clean();
|
||||
SS_Cache::set_cache_lifetime('cacheblock', $cacheOn ? 600 : -1);
|
||||
Cache::factory('cacheblock')->clean();
|
||||
Cache::set_cache_lifetime('cacheblock', $cacheOn ? 600 : -1);
|
||||
}
|
||||
|
||||
protected function _runtemplate($template, $data = null) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\ContentNegotiator;
|
||||
use SilverStripe\Control\SS_HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
@ -674,12 +674,12 @@ after')
|
||||
// Check that the content negotiator converts to the equally legal formats
|
||||
$negotiator = new ContentNegotiator();
|
||||
|
||||
$response = new SS_HTTPResponse($this->render($tmpl1));
|
||||
$response = new HTTPResponse($this->render($tmpl1));
|
||||
$negotiator->html($response);
|
||||
$this->assertRegExp('/<head><base href=".*"><!--\[if lte IE 6\]><\/base><!\[endif\]--><\/head>/',
|
||||
$response->getBody());
|
||||
|
||||
$response = new SS_HTTPResponse($this->render($tmpl1));
|
||||
$response = new HTTPResponse($this->render($tmpl1));
|
||||
$negotiator->xhtml($response);
|
||||
$this->assertRegExp('/<head><base href=".*" \/><\/head>/', $response->getBody());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user