pop example

$this->assertSame('1', $current_route_match->getParameter('foo'));

    // Subrequest.     $subrequest = new Request();
    $subrequest->attributes->set(RouteObjectInterface::ROUTE_NAME, 'test_subrequest_route');
    $subrequest->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/test-subrequest-route/{foo}'));
    $subrequest->attributes->set('foo', '2');
    $request_stack->push($subrequest);
    $this->assertSame('2', $current_route_match->getParameter('foo'));

    // Restored original request.     $request_stack->pop();
    $this->assertSame('1', $current_route_match->getParameter('foo'));
  }

  /** * @covers ::getRouteMatchFromRequest */
  public function testGetRouteMatchFromRequestWithRouting() {
    $request_stack = new RequestStack();
    $request = new Request();
    $request_stack->push($request);
    $current_route_match = new CurrentRouteMatch($request_stack);

    
$test_user->save();
    \Drupal::service('current_user')->setAccount($test_user);
  }

  /** * Tests form action attribute for XSS. */
  public function testFormActionXss() {
    // Create a new request with a uri which attempts XSS.     $request_stack = \Drupal::service('request_stack');
    /** @var \Symfony\Component\HttpFoundation\RequestStack $original_request */
    $original_request = $request_stack->pop();
    // Just request some more so there is no request left.     $request_stack->pop();
    $request_stack->pop();
    $request = Request::create($original_request->getSchemeAndHttpHost() . '/test/"injected=\'attribute\'close="');
    $request_stack->push($request);

    $form = \Drupal::formBuilder()->getForm($this);
    $markup = \Drupal::service('renderer')->renderRoot($form);
    $this->setRawContent($markup);

    $elements = $this->xpath('//form');
    
'#type' => 'container',
      '#attributes' => [
        'id' => 'sdc-wrapper',
      ],
      'component' => $component,
    ];
    $metadata = $metadata ?: new BubbleableMetadata();
    $context = new RenderContext();
    $renderer = \Drupal::service('renderer');
    $output = $renderer->executeInRenderContext($contextfn () => $renderer->render($component));
    if (!$context->isEmpty()) {
      $metadata->addCacheableDependency($context->pop());
    }
    return new Crawler((string) $output);
  }

}
'DELETE',
      // NULL is used in CLI context which results in a request method of an       // empty string.       '',
      // If no request was even pushed onto the request stack, and hence.       FALSE,
    ];
    foreach ($methods as $method) {
      if ($method === FALSE) {
        $request_stack = $this->container->get('request_stack');
        while ($request_stack->getCurrentRequest()) {
          $request_stack->pop();
        }
        $this->container->set('router.request_context', new RequestContext());
      }

      $requestContext->setMethod($method);
      /** @var \Drupal\Core\Url $url */
      $url = $pathValidator->getUrlIfValidWithoutAccessCheck($entity->toUrl()->toString(TRUE)->getGeneratedUrl());
      $this->assertEquals($method$requestContext->getMethod());
      $this->assertInstanceOf(Url::class$url);
      $this->assertSame(['entity_test' => $entity->id()]$url->getRouteParameters());
    }
  }
if ($e instanceof RequestExceptionInterface) {
                $e = new BadRequestHttpException($e->getMessage()$e);
            }
            if (false === $catch) {
                $this->finishRequest($request$type);

                throw $e;
            }

            return $response = $this->handleThrowable($e$request$type);
        } finally {
            $this->requestStack->pop();

            if ($response instanceof StreamedResponse) {
                $callback = $response->getCallback();
                $requestStack = $this->requestStack;

                $response->setCallback(static function D) use ($request$callback$requestStack) {
                    $requestStack->push($request);
                    try {
                        $callback();
                    } finally {
                        $requestStack->pop();
                    }

  protected $tempStore;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $request = Request::create('/');
    $stack = $this->container->get('request_stack');
    $stack->pop();
    $stack->push($request);

    $this->tempStore = $this->container->get('tempstore.private')->get('anonymous_private_temp_store');
  }

  /** * Tests anonymous can get without a previous set. */
  public function testAnonymousCanUsePrivateTempStoreGet() {
    $actual = $this->tempStore->get('foo');
    $this->assertNull($actual);
  }
$offset = $pos + \strlen($text);

            // opening tag?             if ($open = '/' !== $text[1]) {
                $tag = $matches[1][$i][0];
            } else {
                $tag = $matches[3][$i][0] ?? '';
            }

            if (!$open && !$tag) {
                // </>                 $this->styleStack->pop();
            } elseif (null === $style = $this->createStyleFromString($tag)) {
                $output .= $this->applyCurrentStyle($text$output$width$currentLineLength);
            } elseif ($open) {
                $this->styleStack->push($style);
            } else {
                $this->styleStack->pop($style);
            }
        }

        $output .= $this->applyCurrentStyle(substr($message$offset)$output$width$currentLineLength);

        
if (!$queue) {
            throw new RuntimeException(sprintf('Queue with ID %s not found', $queueId));
        }

        $operations = json_decode($queue->getOperations(), true);

        // Wrap all this into a transaction in order to speed up the progress         // and to be able to roll it back at some point         $connection->beginTransaction();

        try {
            $details = $this->getQueue()->pop($queueId$this->getConfig()->getByNamespace('SwagMultiEdit', 'batchItemsPerRequest', 512));

            if (!empty($details)) {
                $this->updateDetails($details$operations);
                $connection->commit();
            }
        } catch (Exception $e) {
            $connection->rollBack();
            throw new RuntimeException(sprintf('Error updating details: %s', $e->getMessage()), 0, $e);
        }
        $remaining = $queue->getArticleDetails()->count();

        
/** * @dataProvider urlCases */
    public function testUrls(UrlCase $case): void
    {
        $request = new Request();
        $request->attributes->set(RequestTransformer::SALES_CHANNEL_BASE_URL, $case->baseUrl);

        $stack = $this->getContainer()->get('request_stack');

        // remove all request from stack         while ($stack->pop()) {
        }

        $stack->push($request);

        $router = $this->getContainer()->get('router');
        $context = $router->getContext();
        $router->setContext(new RequestContext('', 'GET', $case->host));

        $url = $router->generate($case->route, $case->params, $case->type);

        static::assertSame($case->expected, $url);

        

    else {
      $output = [
        'preview' => $preview,
        'table' => $table,
      ];
    }

    // Ensure that we just remove an additional request we pushed earlier.     // This could happen if $errors was not empty.     if ($request_stack->getCurrentRequest() != $current_request) {
      $request_stack->pop();
    }
    return $output;
  }

  /** * Get the user's current progress through the form stack. * * @return array|bool * FALSE if the user is not currently in a multiple-form stack. Otherwise, * an associative array with the following keys: * - current: The number of the current form on the stack. * - total: The total number of forms originally on the stack. */
$filter_result = $this->container->get('renderer')->executeInRenderContext($render_contextfunction D) use ($text$filters$langcode) {
      $metadata = new BubbleableMetadata();
      foreach ($filters as $filter) {
        /** @var \Drupal\filter\FilterProcessResult $result */
        $result = $filter->process($text$langcode);
        $metadata = $metadata->merge($result);
        $text = $result->getProcessedText();
      }
      return (new FilterProcessResult($text))->merge($metadata);
    });
    if (!$render_context->isEmpty()) {
      $filter_result = $filter_result->merge($render_context->pop());
    }
    return $filter_result;
  }

}
$request->attributes->set(SalesChannelRequest::ATTRIBUTE_DOMAIN_LOCALE, 'en-GB');

        $this->getContainer()->get(RequestStack::class)->push($request);

        // get overwritten string         static::assertEquals(
            $snippet['value'],
            $this->translator->getCatalogue('en-GB')->get('new.unit.test.key')
        );
        static::assertSame(
            $request,
            $this->getContainer()->get(RequestStack::class)->pop()
        );
    }

    public function testSymfonyDefaultTranslationFallback(): void
    {
        $this->translator->reset();
        $catalogue = $this->translator->getCatalogue('en');
        static::assertInstanceOf(MessageCatalogueInterface::class$catalogue->getFallbackCatalogue());
        static::assertEquals('en_GB', $catalogue->getFallbackCatalogue()->getLocale());

        $this->translator->reset();
        
        // Sending undefined fields will throw an UnexpectedFieldException         $keyDiff = array_diff(array_keys($data)$propertyKeys);
        if (\count($keyDiff)) {
            foreach ($keyDiff as $fieldName) {
                $parameters->getContext()->getExceptions()->add(
                    new UnexpectedFieldException($fieldPath . '/' . $fieldName(string) $fieldName)
                );
            }
        }

        foreach ($field->getPropertyMapping() as $nestedField) {
            $kvPair = $stack->pop($nestedField->getPropertyName());

            if ($kvPair === null) {
                // The writer updates the whole field, so there is no possibility to update                 // "some" fields. To enable a merge, we have to respect the $existence state                 // for correct constraint validation. In addition the writer has to be rewritten                 // in order to handle merges.                 if (!$nestedField->is(Required::class)) {
                    continue;
                }

                $kvPair = new KeyValuePair($nestedField->getPropertyName(), null, true);
            }
$block = $this->drupalPlaceBlock('block_content:' . $this->entity->uuid());
    $build = $this->container->get('entity_type.manager')->getViewBuilder('block')->view($block, 'block');

    // Render the block.     // @todo The request stack manipulation won't be necessary once     // https://www.drupal.org/node/2367555 is fixed and the     // corresponding $request->isMethodCacheable() checks are removed from     // Drupal\Core\Render\Renderer.     $request_stack = $this->container->get('request_stack');
    $request_stack->push(new Request());
    $this->container->get('renderer')->renderRoot($build);
    $request_stack->pop();

    // Expected keys, contexts, and tags for the block.     // @see \Drupal\block\BlockViewBuilder::viewMultiple()     $expected_block_cache_keys = ['entity_view', 'block', $block->id()];
    $expected_block_cache_contexts = ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme', 'user.permissions'];
    $expected_block_cache_tags = Cache::mergeTags(['block_view', 'rendered']$block->getCacheTags());
    $expected_block_cache_tags = Cache::mergeTags($expected_block_cache_tags$block->getPlugin()->getCacheTags());

    // Expected contexts and tags for the BlockContent entity.     // @see \Drupal\Core\Entity\EntityViewBuilder::getBuildDefaults().     $expected_entity_cache_contexts = ['theme'];
    
/** * Updates the current frame of the stack. * * @param array &$element * The element of the render array that has just been rendered. The stack * frame for this element will be updated with the bubbleable rendering * metadata of this element. */
  public function update(&$element) {
    // The latest frame represents the bubbleable metadata for the subtree.     $frame = $this->pop();
    // Update the frame, but also update the current element, to ensure it     // contains up-to-date information in case it gets render cached.     $updated_frame = BubbleableMetadata::createFromRenderArray($element)->merge($frame);
    $updated_frame->applyTo($element);
    $this->push($updated_frame);
  }

  /** * Bubbles the stack. * * Whenever another level in the render array has been rendered, the stack * must be bubbled, to merge its rendering metadata with that of the parent * element. */
Home | Imprint | This part of the site doesn't use cookies.