Skip to content

Commit

Permalink
Merge pull request #127 from creative-commoners/pulls/3.0/remove-self
Browse files Browse the repository at this point in the history
ENH Use class name instead of self
  • Loading branch information
GuySartorelli authored Jun 17, 2024
2 parents dec88ce + d395845 commit 85c04fc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/DataFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static function for_extension($extension)
public static function for_extensions($extensions)
{
foreach ($extensions as $extension) {
if ($formatter = self::for_extension($extension)) {
if ($formatter = DataFormatter::for_extension($extension)) {
return $formatter;
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public static function for_mimetype($mimeType)
public static function for_mimetypes($mimetypes)
{
foreach ($mimetypes as $mimetype) {
if ($formatter = self::for_mimetype($mimetype)) {
if ($formatter = DataFormatter::for_mimetype($mimetype)) {
return $formatter;
}
}
Expand Down Expand Up @@ -286,7 +286,7 @@ public function getTotalSize()

/**
* 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
Expand Down
4 changes: 2 additions & 2 deletions src/DataFormatter/JSONDataFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function convertDataObjectToJSONObject(DataObjectInterface $obj, $fields
continue;
}

$fieldValue = self::cast($obj->obj($fieldName));
$fieldValue = JSONDataFormatter::cast($obj->obj($fieldName));
$mappedFieldName = $this->getFieldAlias($className, $fieldName);
$serobj->$mappedFieldName = $fieldValue;
}
Expand Down Expand Up @@ -120,7 +120,7 @@ public function convertDataObjectToJSONObject(DataObjectInterface $obj, $fields
$serobj->$relName = ArrayData::array_to_object(array(
"className" => $relClass,
"href" => "$href.json",
"id" => self::cast($obj->obj($fieldName))
"id" => JSONDataFormatter::cast($obj->obj($fieldName))
));
}

Expand Down
6 changes: 3 additions & 3 deletions src/DataFormatter/XMLDataFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function convertDataObjectSet(SS_List $set, $fields = null)
*/
public function convertStringToArray($strData)
{
return self::xml2array($strData);
return XMLDataFormatter::xml2array($strData);
}

/**
Expand Down Expand Up @@ -299,7 +299,7 @@ private static function xml2array($val, $disableDoctypes = false, $disableExtern
// 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);
}

/**
Expand All @@ -326,7 +326,7 @@ private static function recursiveXMLToArray($xml)
} // for CDATA
$r = [];
foreach ($xml as $key => $value) {
$r[$key] = self::recursiveXMLToArray($value);
$r[$key] = XMLDataFormatter::recursiveXMLToArray($value);
}
// Attributes
if (isset($a)) {
Expand Down
6 changes: 3 additions & 3 deletions src/RestfulServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -362,7 +362,7 @@ protected function getSearchQuery(

/**
* 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
Expand Down Expand Up @@ -884,7 +884,7 @@ protected function getMember()
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];
}
Expand Down

0 comments on commit 85c04fc

Please sign in to comment.