addOutbound example

$this->aliasManager = $alias_manager;

    $this->requestStack = new RequestStack();
    $request = Request::create('/some/path');
    $this->requestStack->push($request);

    $this->context = new RequestContext();
    $this->context->fromRequestStack($this->requestStack);

    $processor = new AliasPathProcessor($this->aliasManager);
    $processor_manager = new PathProcessorManager();
    $processor_manager->addOutbound($processor, 1000);
    $this->processorManager = $processor_manager;

    $this->routeProcessorManager = $this->getMockBuilder('Drupal\Core\RouteProcessor\RouteProcessorManager')
      ->disableOriginalConstructor()
      ->getMock();

    $generator = new UrlGenerator($this->provider, $processor_manager$this->routeProcessorManager, $this->requestStack, ['http', 'https']);
    $generator->setContext($this->context);
    $this->generator = $generator;
  }

  
$parameters = ['test' => 'test'];
    $route_name = 'test_name';

    $processors = [
      10 => $this->getMockProcessor($route_name$route$parameters),
      5 => $this->getMockProcessor($route_name$route$parameters),
      0 => $this->getMockProcessor($route_name$route$parameters),
    ];

    // Add the processors in reverse order.     foreach ($processors as $priority => $processor) {
      $this->processorManager->addOutbound($processor$priority);
    }

    $bubbleable_metadata = new BubbleableMetadata();
    $this->processorManager->processOutbound($route_name$route$parameters$bubbleable_metadata);
    // Default cacheability is: permanently cacheable, no cache tags/contexts.     $this->assertEquals((new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)$bubbleable_metadata);
  }

  /** * Returns a mock Route processor object. * * @param string $route_name * The route name. * @param \Symfony\Component\Routing\Route $route * The Route to use in mock with() expectation. * @param array $parameters * The parameters to use in mock with() expectation. * * @return \Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface|\PHPUnit\Framework\MockObject\MockObject */
Home | Imprint | This part of the site doesn't use cookies.