Delete menu with his menu links.

@param  string $lang
@param  int    $menuID
@return array
509389
public function deleteMenu($lang, $menuID)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Menu', 'delete')) {
            return $this->noPermission();
        }

        $menu = Menu::find($menuID);
        if(!$menu) {
            return $this->response("Menu doesn't exist", 400);
        }

        if(!$menu->isPrimary) {
            $menuLinks = MenuLink::where('menuID', $menuID);
            $menuLinks->delete();
            $menu->delete();
            return $this->response("Menu deleted", 200, Menu::getPrimaryMenuID());
        }else{
            return $this->response("Primary menu can not be deleted", 400);
        }
    }
1335450
public function add($menuId)
    {
        $this->loadModel('Menu.Menus');
        $this->loadModel('Content.Contents');
        $menu = $this->Menus->get($menuId);
        $link = $this->Menus->MenuLinks->newEntity();
        $link->set([
            'activation' => 'auto',
            'status' => 1,
            'menu_id' => $menuId
        ]);
        $this->Menus->MenuLinks->addBehavior('Tree', [
            'scope' => ['menu_id' => $menu->id]
        ]);

        if ($this->request->data()) {
            $link = $this->Menus->MenuLinks->patchEntity($link, $this->request->data, [
                'fieldList' => [
                    'parent_id',
                    'title',
                    'url',
                    'description',
                    'target',
                    'expanded',
                    'active',
                    'activation',
                    'status'
                ]
            ]);

            if ($this->Menus->MenuLinks->save($link)) {
                $this->Menus->MenuLinks->recover();
                $this->Flash->success(__d('menu', 'Link successfully created!'));

                if (!empty($this->request->data['action_add'])) {
                    $this->redirect(['plugin' => 'Menu', 'controller' => 'links', 'action' => 'add', $menuId]);
                } elseif (!empty($this->request->data['action_menu'])) {
                    $this->redirect(['plugin' => 'Menu', 'controller' => 'links', 'action' => 'menu', $menuId]);
                }
            } else {
                $this->Flash->danger(__d('menu', 'Link could not be saved, please check your information'));
            }
        }

        $contentLinks = [];
        $contents = $this->Contents
            ->find()
            ->select(['id', 'slug', 'content_type_slug', 'title'])
            ->all();
        foreach ($contents as $content) {
            $contentLinks[stripLanguagePrefix($content->get('url'))] = __d('menu', '{0} [{1}]', [
                $content->title,
                $content->content_type_slug
            ]);
        }

        $parentsTree = $this->Menus->MenuLinks
            ->find('treeList', ['spacer' => '--'])
            ->map(function ($link) {
                if (strpos($link, '-') !== false) {
                    $link = str_replace_last('-', '- ', $link);
                }

                return $link;
            });

        $this->title(__d('menu', 'Create New Link'));
        $this->set(compact('menu', 'link', 'contentLinks', 'parentsTree'));
        $this->Breadcrumb
            ->push('/admin/menu/manage')
            ->push(__d('menu', 'Editing menu "{0}"', $menu->title), ['plugin' => 'Menu', 'controller' => 'manage', 'action' => 'edit', $menuId])
            ->push(__d('menu', 'Links'), ['plugin' => 'Menu', 'controller' => 'links', 'action' => 'menu', $menuId])
            ->push(__d('menu', 'Add new link'), '#');
    }
464969
public static function getAllUrlByMenuId($menuId)
    {
        $records = static::find()
            ->findByMenuId($menuId)
            ->innerJoinWith('menuUrl')
            ->all();

        $return = [];
        if ($records) {
            foreach ($records as $record) {
                $return[] = $record->getMenuUrlData();
            }
        }

        return $return;
    }
1042493
public function delete(string $id = null): void
    {
        $this->request->allowMethod(['post', 'delete']);
        $menu = $this->Menus->get($id);
        if ($this->Menus->delete($menu)) {
            $this->Flash->success((string)__('The menu has been deleted.'));
        } else {
            $this->Flash->error((string)__('The menu could not be deleted. Please, try again.'));
        }

        $this->redirect(['action' => 'index']);
    }
359915
public function findOneByPageIdAndByLanguageId($pageId, $languageId)
    {
        $documentCollection = $this->findByPageIdAndByLanguageId($pageId, $languageId);
        return reset($documentCollection);
    }
123453
public function delete($id)
    {
        $this->loadModel('Menu.MenuLinks');
        $link = $this->MenuLinks->get($id);
        $this->MenuLinks->addBehavior('Tree', ['scope' => ['menu_id' => $link->menu_id]]);
        $this->MenuLinks->removeFromTree($link);

        if ($this->MenuLinks->delete($link)) {
            $this->Flash->success(__d('menu', 'Link successfully removed!'));
        } else {
            $this->Flash->danger(__d('menu', 'Link could not be removed, please try again'));
        }

        $this->title(__d('menu', 'Delete Link'));
        $this->redirect($this->referer());
    }
39980
public function delete($lang, $id)
    {
        if(!User::hasAccess('Categories', 'delete')) {
            return $this->noPermission();
        }

        $categoryDeleteRes = $this->deleteCategory($id);
        if(gettype($categoryDeleteRes) == "boolean") {
            if($categoryDeleteRes) {
                return $this->response('Category could not be deleted.', 500);
            }
        }else{
            return $categoryDeleteRes;
        }

        return $this->response('Category could not be deleted. Please try again later or contact your Administrator!', 500);
    }
754364
public function deleteAction($id, Request $request, $menuId = null)
    {
        $this->menuId = $menuId;

        return parent::deleteAction($id, $request);
    }
1005252
public function find($id, $lang = null)
  {
    $results = $this->client->request([
      'ids' => $id,
      'languages' => $lang
    ]);

    if($results->isEmpty()) {
      return null;
    }

    return $results->first();
  }
589212
public function deleteConditional(string $menuId)
    {
        $url = $this->getUrl('delconditional');
        $data = ['menuid' => $menuId];
        $request = urlencode(json_encode($data));
        $json = $this->curl->post($url, $request);

        return $json;
    }
989597
public function destroy($id, $translationId)
    {
        $block = $this->getBlock($id);
        if (!empty($block)) {
            $this->authorize('delete', $block);
            $translation = $this->repository->getBlockTranslationById($block, $translationId);
            if (!empty($translation)) {
                try {
                    $this->repository->deleteTranslation($translation);
                    return $this->respondWithSimpleSuccess(['success' => true]);
                } catch (RepositoryValidationException $e) {
                    return $this->respondWithError($e->getMessage());
                }
            }
        }
        return $this->respondNotFound();
    }
96741
public function deleteMenu() {
		$data = $this->getData('/cgi-bin/menu/delete', [
			'access_token' => $this->getAccessToken(),
		]);

		return $this->errcode == 0 && WechatMenu::deleteAll(['appid' => $this->app->appid]);
	}
188515
public function getMenu($menuTypeId, $language = null)
    {
        if( is_null($language) ) {
            $language = app()->getLocale();
        }

        if( $this->cacheEnabled ) {
            $cacheName = self::getCacheName($menuTypeId, $language);

            if( Cache::has($cacheName) ) {
                return Cache::get($cacheName);
            }
        }

        return $this->getMenuItems($menuTypeId, $language);
    }
474137
public function deleteRichMenu($richMenuId)
    {
        $url = sprintf('%s/v2/bot/richmenu/%s', $this->endpointBase, urlencode($richMenuId));
        return $this->httpClient->delete($url);
    }
660150
public function getNodeTranslationByNodeIdQueryBuilder($nodeId, $lang)
    {
        $qb = $this->createQueryBuilder('nt')
            ->select('nt')
            ->innerJoin('nt.node', 'n', 'WITH', 'nt.node = n.id')
            ->where('n.deleted != 1')
            ->andWhere('nt.online = 1')
            ->andWhere('nt.lang = :lang')
            ->setParameter('lang', $lang)
            ->andWhere('n.id = :node_id')
            ->setParameter('node_id', $nodeId)
            ->setFirstResult(0)
            ->setMaxResults(1);

        return $qb->getQuery()->getOneOrNullResult();
    }
839714
public function delConditional($menuid)
    {
        $url = "https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['menuid' => $menuid]);
    }
435558
public function unlinkRichMenu($userId)
    {
        $url = sprintf('%s/v2/bot/user/%s/richmenu', $this->endpointBase, urlencode($userId));
        return $this->httpClient->delete($url);
    }