develop #63

Merged
chris merged 14 commits from develop into main 2022-04-23 21:10:16 +02:00
1 changed files with 19 additions and 17 deletions
Showing only changes of commit 3657873be7 - Show all commits

View File

@ -2,13 +2,15 @@
use Zend\Http\Client; use Zend\Http\Client;
$client = New Client;
$client = new Client('https://dev.arc-hive.zone/wp-json/menus/v1/menus/4'); $client = new Client('https://dev.arc-hive.zone/wp-json/menus/v1/menus/4');
$client->setOptions(array("timeout"=>1));
$response = $client->send(); $response = $client->send();
$response_items = json_decode($response->getBody()); $response_data = json_decode($response->getBody());
$items = new ArrayObject(); $items = new ArrayObject;
$items[0] = new ArrayObject();
foreach ($response_items as $menu_item) { if (!$response->isClientError()&& $response_data) {
foreach ($response_data as $menu_item) {
$item_url = $menu_item->url; $item_url = $menu_item->url;
if (strtolower($menu_item->title) == 'login') { if (strtolower($menu_item->title) == 'login') {
$item_url = "/login"; $item_url = "/login";
@ -16,13 +18,13 @@ foreach ($response_items as $menu_item) {
$item = [ $item = [
"ID" => $menu_item->ID, "ID" => $menu_item->ID,
"title" => $menu_item->title, "title" => $menu_item->title,
"url" => $item_url, "url" => $item_url
"menu_item_parent" => $menu_item->menu_item_parent,
]; ];
if (!array_key_exists($menu_item->menu_item_parent, $items)) { if (!array_key_exists($menu_item->menu_item_parent, $items)) {
$items[$menu_item->menu_item_parent] = new ArrayObject(); $items[$menu_item->menu_item_parent] = new ArrayObject();
} }
$items[$menu_item->menu_item_parent][$menu_item->ID] =$item; $items[$menu_item->menu_item_parent][$menu_item->ID] =$item;
}
} }
//print_r($items); //print_r($items);