mirror of
https://github.com/friendica/friendica
synced 2025-04-19 13:50:15 +00:00
Moved function to Arrays.php
This commit is contained in:
parent
fbde999d0d
commit
a66bb09b40
3 changed files with 39 additions and 37 deletions
|
@ -29,6 +29,7 @@ use Friendica\Model\Post;
|
|||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Security\BasicAuth;
|
||||
use Friendica\Security\OAuth;
|
||||
use Friendica\Util\Arrays;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\HTTPInputData;
|
||||
use Friendica\Util\XML;
|
||||
|
@ -384,34 +385,6 @@ class BaseApi extends BaseModule
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* walks recursively through an array with the possibility to change value and key
|
||||
*
|
||||
* @param array $array The array to walk through
|
||||
* @param callable $callback The callback function
|
||||
*
|
||||
* @return array the transformed array
|
||||
*/
|
||||
static public function walkRecursive(array &$array, callable $callback)
|
||||
{
|
||||
$new_array = [];
|
||||
|
||||
foreach ($array as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
if ($callback($v, $k)) {
|
||||
$new_array[$k] = self::walkRecursive($v, $callback);
|
||||
}
|
||||
} else {
|
||||
if ($callback($v, $k)) {
|
||||
$new_array[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
$array = $new_array;
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the data according to the data type
|
||||
*
|
||||
|
@ -484,7 +457,7 @@ class BaseApi extends BaseModule
|
|||
|
||||
if (is_array($data2)) {
|
||||
$key = key($data2);
|
||||
self::walkRecursive($data2, ['Friendica\Module\BaseApi', 'reformatXML']);
|
||||
Arrays::walkRecursive($data2, ['Friendica\Module\BaseApi', 'reformatXML']);
|
||||
|
||||
if ($key == '0') {
|
||||
$data4 = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue