getLocalTasksForRoute example

 while ($next_parent);
      }

    }
    return $this->instances[$route_name];
  }

  /** * {@inheritdoc} */
  public function getTasksBuild($current_route_name, RefinableCacheableDependencyInterface &$cacheability) {
    $tree = $this->getLocalTasksForRoute($current_route_name);
    $build = [];

    // Collect all route names.     $route_names = [];
    foreach ($tree as $instances) {
      foreach ($instances as $child) {
        $route_names[] = $child->getRouteName();
      }
    }
    // Pre-fetch all routes involved in the tree. This reduces the number     // of SQL queries that would otherwise be triggered by the access manager.

  protected function assertLocalTasks($route_name$expected_tasks$route_params = []) {

    $directory_list = [];
    foreach ($this->directoryList as $key => $value) {
      $directory_list[$key] = $this->root . '/' . $value;
    }

    $manager = $this->getLocalTaskManager($directory_list$route_name$route_params);

    $tmp_tasks = $manager->getLocalTasksForRoute($route_name);

    // At this point we're just testing existence so pull out keys and then     // compare.     //     // Deeper testing would require a functioning factory which because we are     // using the DefaultPluginManager base means we get into dependency soup     // because its factories create method and pulling services off the \Drupal     // container.     $tasks = [];
    foreach ($tmp_tasks as $level => $level_tasks) {
      $tasks[$level] = array_keys($level_tasks);
    }
$definitions = $this->getLocalTaskFixtures();

    $this->pluginDiscovery->expects($this->once())
      ->method('getDefinitions')
      ->willReturn($definitions);

    $mock_plugin = $this->createMock('Drupal\Core\Menu\LocalTaskInterface');

    $this->setupFactory($mock_plugin);
    $this->setupLocalTaskManager();

    $local_tasks = $this->manager->getLocalTasksForRoute('menu_local_task_test_tasks_view');

    $result = $this->getLocalTasksForRouteResult($mock_plugin);

    $this->assertEquals($result$local_tasks);
  }

  /** * Tests the getLocalTasksForRoute method on a child. * * @see \Drupal\system\Plugin\Type\MenuLocalTaskManager::getLocalTasksForRoute() */
  
Home | Imprint | This part of the site doesn't use cookies.