Loading rest_menu_items.api.php +16 −1 Original line number Diff line number Diff line Loading @@ -17,8 +17,23 @@ * @param string $menu_name * The menu name. */ function hook_rest_menu_items_resource_manipulators_alter(array $manipulators, $menu_name) { function hook_rest_menu_items_resource_manipulators_alter(array &$manipulators, &$menu_name) { if ($menu_name === 'main') { $manipulators[] = ['callable' => 'custom.manipulator:method']; } } /** * Alter the output of the menu_items array. * * @param array $menu_items * The menu items array. */ function hook_rest_menu_items_output_alter(array &$menu_items) { foreach ($menu_items as &$menu_item) { if (array_key_exists('below', $menu_item)) { $menu_item['child'] = $menu_item['below']; unset($menu_item['below']); } } } src/Plugin/rest/resource/RestMenuItemsResource.php +4 −1 Original line number Diff line number Diff line Loading @@ -164,6 +164,9 @@ class RestMenuItemsResource extends ResourceBase { $this->getMenuItems($menu['#items'], $this->menuItems); // Other modules can alter the output before rendering. $this->moduleHandler->alter('rest_menu_items_output', $this->menuItems); // Return response. $response = new ResourceResponse(array_values($this->menuItems)); Loading Loading
rest_menu_items.api.php +16 −1 Original line number Diff line number Diff line Loading @@ -17,8 +17,23 @@ * @param string $menu_name * The menu name. */ function hook_rest_menu_items_resource_manipulators_alter(array $manipulators, $menu_name) { function hook_rest_menu_items_resource_manipulators_alter(array &$manipulators, &$menu_name) { if ($menu_name === 'main') { $manipulators[] = ['callable' => 'custom.manipulator:method']; } } /** * Alter the output of the menu_items array. * * @param array $menu_items * The menu items array. */ function hook_rest_menu_items_output_alter(array &$menu_items) { foreach ($menu_items as &$menu_item) { if (array_key_exists('below', $menu_item)) { $menu_item['child'] = $menu_item['below']; unset($menu_item['below']); } } }
src/Plugin/rest/resource/RestMenuItemsResource.php +4 −1 Original line number Diff line number Diff line Loading @@ -164,6 +164,9 @@ class RestMenuItemsResource extends ResourceBase { $this->getMenuItems($menu['#items'], $this->menuItems); // Other modules can alter the output before rendering. $this->moduleHandler->alter('rest_menu_items_output', $this->menuItems); // Return response. $response = new ResourceResponse(array_values($this->menuItems)); Loading