mirror of
https://github.com/silverstripe/silverstripe-restfulserver
synced 2024-10-22 14:05:58 +02:00
ENH Use class name instead of self
This commit is contained in:
parent
dec88ce497
commit
d395845eb1
@ -136,7 +136,7 @@ abstract class DataFormatter
|
|||||||
public static function for_extensions($extensions)
|
public static function for_extensions($extensions)
|
||||||
{
|
{
|
||||||
foreach ($extensions as $extension) {
|
foreach ($extensions as $extension) {
|
||||||
if ($formatter = self::for_extension($extension)) {
|
if ($formatter = DataFormatter::for_extension($extension)) {
|
||||||
return $formatter;
|
return $formatter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ abstract class DataFormatter
|
|||||||
public static function for_mimetypes($mimetypes)
|
public static function for_mimetypes($mimetypes)
|
||||||
{
|
{
|
||||||
foreach ($mimetypes as $mimetype) {
|
foreach ($mimetypes as $mimetype) {
|
||||||
if ($formatter = self::for_mimetype($mimetype)) {
|
if ($formatter = DataFormatter::for_mimetype($mimetype)) {
|
||||||
return $formatter;
|
return $formatter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ abstract class DataFormatter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all fields on the object which should be shown
|
* Returns all fields on the object which should be shown
|
||||||
* in the output. Can be customised through {@link self::setCustomFields()}.
|
* in the output. Can be customised through {@link DataFormatter::setCustomFields()}.
|
||||||
*
|
*
|
||||||
* @param DataObject $obj
|
* @param DataObject $obj
|
||||||
* @return array
|
* @return array
|
||||||
|
@ -89,7 +89,7 @@ class JSONDataFormatter extends DataFormatter
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fieldValue = self::cast($obj->obj($fieldName));
|
$fieldValue = JSONDataFormatter::cast($obj->obj($fieldName));
|
||||||
$mappedFieldName = $this->getFieldAlias($className, $fieldName);
|
$mappedFieldName = $this->getFieldAlias($className, $fieldName);
|
||||||
$serobj->$mappedFieldName = $fieldValue;
|
$serobj->$mappedFieldName = $fieldValue;
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ class JSONDataFormatter extends DataFormatter
|
|||||||
$serobj->$relName = ArrayData::array_to_object(array(
|
$serobj->$relName = ArrayData::array_to_object(array(
|
||||||
"className" => $relClass,
|
"className" => $relClass,
|
||||||
"href" => "$href.json",
|
"href" => "$href.json",
|
||||||
"id" => self::cast($obj->obj($fieldName))
|
"id" => JSONDataFormatter::cast($obj->obj($fieldName))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ class XMLDataFormatter extends DataFormatter
|
|||||||
*/
|
*/
|
||||||
public function convertStringToArray($strData)
|
public function convertStringToArray($strData)
|
||||||
{
|
{
|
||||||
return self::xml2array($strData);
|
return XMLDataFormatter::xml2array($strData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -299,7 +299,7 @@ class XMLDataFormatter extends DataFormatter
|
|||||||
// This will throw an exception if the XML contains references to any internal entities
|
// This will throw an exception if the XML contains references to any internal entities
|
||||||
// that were defined in an <!ENTITY /> before it was removed
|
// that were defined in an <!ENTITY /> before it was removed
|
||||||
$xml = new SimpleXMLElement($val ?? '');
|
$xml = new SimpleXMLElement($val ?? '');
|
||||||
return self::recursiveXMLToArray($xml);
|
return XMLDataFormatter::recursiveXMLToArray($xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -326,7 +326,7 @@ class XMLDataFormatter extends DataFormatter
|
|||||||
} // for CDATA
|
} // for CDATA
|
||||||
$r = [];
|
$r = [];
|
||||||
foreach ($xml as $key => $value) {
|
foreach ($xml as $key => $value) {
|
||||||
$r[$key] = self::recursiveXMLToArray($value);
|
$r[$key] = XMLDataFormatter::recursiveXMLToArray($value);
|
||||||
}
|
}
|
||||||
// Attributes
|
// Attributes
|
||||||
if (isset($a)) {
|
if (isset($a)) {
|
||||||
|
@ -48,7 +48,7 @@ class RestfulServer extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* If no extension is given in the request, resolve to this extension
|
* If no extension is given in the request, resolve to this extension
|
||||||
* (and subsequently the {@link self::$default_mimetype}.
|
* (and subsequently the {@link RestfulServer::$default_mimetype}.
|
||||||
*
|
*
|
||||||
* @config
|
* @config
|
||||||
* @var string
|
* @var string
|
||||||
@ -362,7 +362,7 @@ class RestfulServer extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a dataformatter instance based on the request
|
* Returns a dataformatter instance based on the request
|
||||||
* extension or mimetype. Falls back to {@link self::$default_extension}.
|
* extension or mimetype. Falls back to {@link RestfulServer::$default_extension}.
|
||||||
*
|
*
|
||||||
* @param boolean $includeAcceptHeader Determines wether to inspect and prioritize any HTTP Accept headers
|
* @param boolean $includeAcceptHeader Determines wether to inspect and prioritize any HTTP Accept headers
|
||||||
* @param string Classname of a DataObject
|
* @param string Classname of a DataObject
|
||||||
@ -884,7 +884,7 @@ class RestfulServer extends Controller
|
|||||||
protected function resolveClassName(HTTPRequest $request)
|
protected function resolveClassName(HTTPRequest $request)
|
||||||
{
|
{
|
||||||
$className = $request->param('ClassName');
|
$className = $request->param('ClassName');
|
||||||
$aliases = self::config()->get('endpoint_aliases');
|
$aliases = static::config()->get('endpoint_aliases');
|
||||||
|
|
||||||
return empty($aliases[$className]) ? $this->unsanitiseClassName($className) : $aliases[$className];
|
return empty($aliases[$className]) ? $this->unsanitiseClassName($className) : $aliases[$className];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user