getTasksBuild example

$cacheability = new CacheableMetadata();
      $cacheability->addCacheContexts(['route']);
      // Look for route-based tabs.       $this->taskData[$route_name] = [
        'tabs' => [],
        'cacheability' => $cacheability,
      ];

      if (!$this->requestStack->getCurrentRequest()->attributes->has('exception')) {
        // Safe to build tasks only when no exceptions raised.         $data = [];
        $local_tasks = $this->getTasksBuild($route_name$cacheability);
        foreach ($local_tasks as $tab_level => $items) {
          $data[$tab_level] = empty($data[$tab_level]) ? $items : array_merge($data[$tab_level]$items);
        }
        $this->taskData[$route_name]['tabs'] = $data;
        // Allow modules to alter local tasks.         $this->moduleHandler->alter('menu_local_tasks', $this->taskData[$route_name]$route_name$cacheability);
        $this->taskData[$route_name]['cacheability'] = $cacheability;
      }
    }

    if (isset($this->taskData[$route_name]['tabs'][$level])) {
      
->method('getArguments')
      ->willReturn([]);

    $this->routeMatch->expects($this->any())
      ->method('getRouteName')
      ->willReturn('menu_local_task_test_tasks_view');
    $this->routeMatch->expects($this->any())
      ->method('getRawParameters')
      ->willReturn(new InputBag());

    $cacheability = new CacheableMetadata();
    $this->manager->getTasksBuild('menu_local_task_test_tasks_view', $cacheability);

    // Ensure that all cacheability metadata is merged together.     $this->assertEqualsCanonicalizing(['tag.example1', 'tag.example2']$cacheability->getCacheTags());
    $this->assertEqualsCanonicalizing(['context.example1', 'context.example2', 'route', 'user.permissions']$cacheability->getCacheContexts());
  }

  protected function setupFactoryAndLocalTaskPlugins(array $definitions$active_plugin_id) {
    $map = [];
    $access_manager_map = [];

    foreach ($definitions as $plugin_id => $info) {
      
Home | Imprint | This part of the site doesn't use cookies.