/**
 *	Asserts that we create a new search page and remove it again
 */
function testNewAndRemoveSearchPage()
{
    // Create a new search page
    $this->drupalLogin($this->admin_user);
    $this->drupalGet('admin/config/search/apachesolr/search-pages');
    $this->assertText(t('Add search page'), t('Create new search page link is available'));
    $this->clickLink(t('Add search page'));
    $this->assertText(t('The human-readable name of the search page configuration.'), t('Search page creation page succesfully added'));
    $edit = array('page_id' => 'solr_testingsuite', 'env_id' => 'solr', 'label' => 'Test Search Page', 'description' => 'Test Description', 'page_title' => 'Test Title', 'search_path' => 'search/searchdifferentpath');
    $this->drupalPost($this->getUrl(), $edit, t('Save configuration'));
    $this->assertResponse(200);
    // Make sure the menu is recognized
    drupal_static_reset('apachesolr_search_page_load');
    menu_cache_clear_all();
    menu_rebuild();
    $this->drupalGet('admin/config/search/apachesolr/search-pages');
    $this->assertText(t('Test Search Page'), t('Search Page was succesfully created'));
    // Remove the same environment
    $this->clickLink(t('Delete'));
    $this->assertText(t('search page configuration will be deleted.This action cannot be undone.'), t('Delete confirmation page was succesfully loaded'));
    $this->drupalPost($this->getUrl(), array(), t('Delete page'));
    $this->assertResponse(200);
    drupal_static_reset('apachesolr_search_page_load');
    $this->drupalGet('admin/config/search/apachesolr/search-pages');
    $this->assertNoText(t('Test Search Page'), t('Search Environment was succesfully deleted'));
}
 /**
  * Perform menu-specific rebuilding.
  */
 protected function menuLinksRebuild()
 {
     if ($this->lock->acquire(__FUNCTION__)) {
         $transaction = db_transaction();
         try {
             // Ensure the menu links are up to date.
             menu_link_rebuild_defaults();
             // Clear the menu cache.
             menu_cache_clear_all();
             // Track which menu items are expanded.
             _menu_update_expanded_menus();
         } catch (\Exception $e) {
             $transaction->rollback();
             watchdog_exception('menu', $e);
         }
         $this->lock->release(__FUNCTION__);
     } else {
         // Wait for another request that is already doing this work.
         // We choose to block here since otherwise the router item may not
         // be available during routing resulting in a 404.
         $this->lock->wait(__FUNCTION__);
     }
 }
 public function flush_menu()
 {
     menu_cache_clear_all();
     $this->menuLinkManager->rebuild();
     $this->contextualLinkManager->clearCachedDefinitions();
     $this->localTaskLinkManager->clearCachedDefinitions();
     $this->localActionLinkManager->clearCachedDefinitions();
     drupal_set_message($this->t('All cached menu data cleared.'));
     return new RedirectResponse($this->reload_page());
 }
Example #4
0
 public function flush_menu()
 {
     menu_cache_clear_all();
     drupal_set_message($this->t('All cached menu data cleared.'));
     return new RedirectResponse($this->reload_page());
 }
/**
 * Delete a custom menu and all contained links.
 *
 * Note that this function deletes all menu links in a custom menu. While menu
 * links derived from router paths may be restored by rebuilding the menu, all
 * customized and custom links will be irreversibly gone. Therefore, this
 * function should usually be called from a user interface (form submit) handler
 * only, which allows the user to confirm the action.
 *
 * @param $menu
 *   An array representing a custom menu:
 *   - menu_name: The unique name of the custom menu.
 *   - title: The human readable menu title.
 *   - description: The custom menu description.
 *
 * Modules should always pass a fully populated $menu when deleting a custom
 * menu, so other modules are able to output proper status or watchdog messages.
 *
 * @see menu_load()
 *
 * menu_delete_links() will take care of clearing the page cache. Other modules
 * should take care of their menu-related data by implementing
 * hook_menu_delete().
 */
function menu_delete($menu)
{
    // Delete all links from the menu.
    menu_delete_links($menu['menu_name']);
    // Remove menu from active menus variable.
    $active_menus = variable_get('menu_default_active_menus', array_keys(menu_get_menus()));
    foreach ($active_menus as $i => $menu_name) {
        if ($menu['menu_name'] == $menu_name) {
            unset($active_menus[$i]);
            variable_set('menu_default_active_menus', $active_menus);
        }
    }
    // Delete the custom menu.
    db_delete('menu_custom')->condition('menu_name', $menu['menu_name'])->execute();
    menu_cache_clear_all();
    module_invoke_all('menu_delete', $menu);
}