ENH Use class name instead of self

This commit is contained in:
Steve Boyd 2024-06-14 21:46:22 +12:00
parent dec88ce497
commit d395845eb1
4 changed files with 11 additions and 11 deletions

View File

@ -136,7 +136,7 @@ abstract class DataFormatter
public static function for_extensions($extensions)
{
foreach ($extensions as $extension) {
if ($formatter = self::for_extension($extension)) {
if ($formatter = DataFormatter::for_extension($extension)) {
return $formatter;
}
}
@ -178,7 +178,7 @@ abstract class DataFormatter
public static function for_mimetypes($mimetypes)
{
foreach ($mimetypes as $mimetype) {
if ($formatter = self::for_mimetype($mimetype)) {
if ($formatter = DataFormatter::for_mimetype($mimetype)) {
return $formatter;
}
}
@ -286,7 +286,7 @@ abstract class DataFormatter
/**
* 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
* @return array

View File

@ -89,7 +89,7 @@ class JSONDataFormatter extends DataFormatter
continue;
}
$fieldValue = self::cast($obj->obj($fieldName));
$fieldValue = JSONDataFormatter::cast($obj->obj($fieldName));
$mappedFieldName = $this->getFieldAlias($className, $fieldName);
$serobj->$mappedFieldName = $fieldValue;
}
@ -120,7 +120,7 @@ class JSONDataFormatter extends DataFormatter
$serobj->$relName = ArrayData::array_to_object(array(
"className" => $relClass,
"href" => "$href.json",
"id" => self::cast($obj->obj($fieldName))
"id" => JSONDataFormatter::cast($obj->obj($fieldName))
));
}

View File

@ -262,7 +262,7 @@ class XMLDataFormatter extends DataFormatter
*/
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
// that were defined in an <!ENTITY /> before it was removed
$xml = new SimpleXMLElement($val ?? '');
return self::recursiveXMLToArray($xml);
return XMLDataFormatter::recursiveXMLToArray($xml);
}
/**
@ -326,7 +326,7 @@ class XMLDataFormatter extends DataFormatter
} // for CDATA
$r = [];
foreach ($xml as $key => $value) {
$r[$key] = self::recursiveXMLToArray($value);
$r[$key] = XMLDataFormatter::recursiveXMLToArray($value);
}
// Attributes
if (isset($a)) {

View File

@ -48,7 +48,7 @@ class RestfulServer extends Controller
/**
* 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
* @var string
@ -362,7 +362,7 @@ class RestfulServer extends Controller
/**
* 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 string Classname of a DataObject
@ -884,7 +884,7 @@ class RestfulServer extends Controller
protected function resolveClassName(HTTPRequest $request)
{
$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];
}