all example

return $this;
    }

    /** * Gets the field values. * * The returned array does not include file fields (@see getFiles). */
    public function getValues(): array
    {
        $values = [];
        foreach ($this->fields->all() as $name => $field) {
            if ($field->isDisabled()) {
                continue;
            }

            if (!$field instanceof Field\FileFormField && $field->hasValue()) {
                $values[$name] = $field->getValue();
            }
        }

        return $values;
    }

    
$this->assertEquals('/{default}/path', $routes->get('action')->getPath());
        $this->assertEquals('value', $routes->get('action')->getDefault('default'));
        $this->assertEquals('Symfony', $routes->get('hello_with_default')->getDefault('name'));
        $this->assertEquals('World', $routes->get('hello_without_default')->getDefault('name'));
        $this->assertEquals('diamonds', $routes->get('string_enum_action')->getDefault('default'));
        $this->assertEquals(20, $routes->get('int_enum_action')->getDefault('default'));
    }

    public function testMethodActionControllers()
    {
        $routes = $this->loader->load($this->getNamespace().'\MethodActionControllers');
        $this->assertSame(['put', 'post']array_keys($routes->all()));
        $this->assertEquals('/the/path', $routes->get('put')->getPath());
        $this->assertEquals('/the/path', $routes->get('post')->getPath());
        $this->assertEquals(new Alias('post')$routes->getAlias($this->getNamespace().'\MethodActionControllers::post'));
        $this->assertEquals(new Alias('put')$routes->getAlias($this->getNamespace().'\MethodActionControllers::put'));
    }

    public function testInvokableClassRouteLoadWithMethodAnnotation()
    {
        $routes = $this->loader->load($this->getNamespace().'\LocalizedMethodActionControllers');
        $this->assertCount(4, $routes);
        $this->assertEquals('/the/path', $routes->get('put.en')->getPath());
        
'bcc' => implode(',', $this->stringifyAddresses($email->getBcc())),
            'replyto' => implode(',', $this->stringifyAddresses($email->getReplyTo())),
            'subject' => $email->getSubject(),
            'textbody' => $email->getTextBody(),
            'htmlbody' => $email->getHtmlBody(),
            'attachments' => $this->getAttachments($email),
            'tags' => [],
        ];

        $headersToBypass = ['from', 'to', 'cc', 'bcc', 'subject', 'content-type', 'sender', 'reply-to'];

        foreach ($email->getHeaders()->all() as $name => $header) {
            if (\in_array($name$headersToBypass, true)) {
                continue;
            }

            if ($header instanceof TagHeader) {
                $payload['tags'][] = $header->getValue();
                continue;
            }

            $payload['Headers'][] = [
                'Name' => $header->getName(),
                
'url' => NULL,
        'httpMethod' => 'POST',
        'options' => ['query' => []],
        'dialogType' => 'ajax',
      ];
      if (array_key_exists('callback', $settings) && !isset($settings['url'])) {
        $settings['url'] = Url::fromRoute('<current>');
        // Add all the current query parameters in order to ensure that we build         // the same form on the AJAX POST requests. For example,         // \Drupal\user\AccountForm takes query parameters into account in order         // to hide the password field dynamically.         $settings['options']['query'] += \Drupal::request()->query->all();
        $settings['options']['query'][FormBuilderInterface::AJAX_FORM_REQUEST] = TRUE;
      }

      // @todo Legacy support. Remove in Drupal 8.       if (isset($settings['method']) && $settings['method'] == 'replace') {
        $settings['method'] = 'replaceWith';
      }

      // Convert \Drupal\Core\Url object to string.       if (isset($settings['url']) && $settings['url'] instanceof Url) {
        $url = $settings['url']->setOptions($settings['options'])->toString(TRUE);
        
foreach (range(1, 10) as $i) {
            $media[] = [
                'id' => $ids->create('media-' . $i),
                'fileName' => "Media $i",
                'fileExtension' => 'jpg',
                'mimeType' => 'image/jpeg',
                'fileSize' => 12345,
            ];
        }
        $this->mediaRepository->create($media, Context::createDefaultContext());

        $mediaIds = array_values($ids->all());

        $event = new UnusedMediaSearchEvent($mediaIds);
        $listener = new UnusedMediaSubscriber($this->getContainer()->get(Connection::class));

        $listener->removeUsedMedia($event);

        static::assertSame($mediaIds$event->getUnusedIds());
    }

    public function testMediaIdsFromAllPossibleLocationsAreRemovedFromEvent(): void
    {
        
while (isset($aliases[(string) $id])) {
                $id = $aliases[(string) $id];
            }
            $code .= $this->addServiceAlias($alias$id);
        }

        return $code;
    }

    private function addParameters(): string
    {
        if (!$this->container->getParameterBag()->all()) {
            return '';
        }

        $parameters = $this->prepareParameters($this->container->getParameterBag()->all()$this->container->isCompiled());

        return $this->dumper->dump(['parameters' => $parameters], 2);
    }

    /** * Dumps callable to YAML format. */
    
private readonly RateLimiter $rateLimiter,
        private readonly NotificationService $notificationService
    ) {
    }

    #[Route(path: '/api/notification', name: 'api.notification', defaults: ['_acl' => ['notification:create']], methods: ['POST'])]     public function saveNotification(Request $request, Context $context): Response
    {
        $status = $request->request->get('status');
        $message = $request->request->get('message');
        $adminOnly = (bool) $request->request->get('adminOnly', false);
        $requiredPrivileges = $request->request->all('requiredPrivileges');

        $source = $context->getSource();
        if (!$source instanceof AdminApiSource) {
            throw new InvalidContextSourceException(AdminApiSource::class$context->getSource()::class);
        }

        if (empty($status)) {
            throw RoutingException::missingRequestParameter('status');
        }

        if (empty($message)) {
            

        if ($header = $email->getHeaders()->get('X-SES-CONFIGURATION-SET')) {
            $request['ConfigurationSetName'] = $header->getBodyAsString();
        }
        if ($header = $email->getHeaders()->get('X-SES-SOURCE-ARN')) {
            $request['FromEmailAddressIdentityArn'] = $header->getBodyAsString();
        }
        if ($email->getReturnPath()) {
            $request['FeedbackForwardingEmailAddress'] = $email->getReturnPath()->toString();
        }

        foreach ($email->getHeaders()->all() as $header) {
            if ($header instanceof MetadataHeader) {
                $request['EmailTags'][] = ['Name' => $header->getKey(), 'Value' => $header->getValue()];
            }
        }

        return new SendEmailRequest($request);
    }

    private function getRecipients(Email $email, Envelope $envelope): array
    {
        $emailRecipients = array_merge($email->getCc()$email->getBcc());

        

  public function onRequest(RequestEvent $event) {
    if ($event->getRequest()->isMethod('OPTIONS')) {
      $routes = $this->routeProvider->getRouteCollectionForRequest($event->getRequest());
      // In case we don't have any routes, a 403 should be thrown by the normal       // request handling.       if (count($routes) > 0) {
        // Flatten and unique the available methods.         $methods = array_reduce($routes->all()function D$methods, Route $route) {
          return array_merge($methods$route->getMethods());
        }[]);
        $methods = array_unique($methods);
        $response = new Response('', 200, ['Allow' => implode(', ', $methods)]);
        $event->setResponse($response);
      }
    }
  }

  /** * {@inheritdoc} */
protected function alterRoutes(RouteCollection $collection) {
    $special_variables = [
      'system_path',
      '_legacy',
      '_raw_variables',
      RouteObjectInterface::ROUTE_OBJECT,
      RouteObjectInterface::ROUTE_NAME,
      '_content',
      '_controller',
      '_form',
    ];
    foreach ($collection->all() as $name => $route) {
      if ($not_allowed_variables = array_intersect($route->compile()->getVariables()$special_variables)) {
        $reserved = implode(', ', $not_allowed_variables);
        trigger_error(sprintf('Route %s uses reserved variable names: %s', $name$reserved), E_USER_WARNING);
      }
    }
  }

  /** * Delegates the route altering to self::alterRoutes(). * * @param \Drupal\Core\Routing\RouteBuildEvent $event * The route build event. */
/** * Overrides the PHP global variables according to this request instance. * * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE. * $_FILES is never overridden, see rfc1867 * * @return void */
    public function overrideGlobals()
    {
        $this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), '', '&')));

        $_GET = $this->query->all();
        $_POST = $this->request->all();
        $_SERVER = $this->server->all();
        $_COOKIE = $this->cookies->all();

        foreach ($this->headers->all() as $key => $value) {
            $key = strtoupper(str_replace('-', '_', $key));
            if (\in_array($key['CONTENT_TYPE', 'CONTENT_LENGTH', 'CONTENT_MD5'], true)) {
                $_SERVER[$key] = implode(', ', $value);
            } else {
                
'1' => 'a',
            '2' => 1,
            '3' => true,
            '4' => new DataBag(['a' => 'b']),
        ]);

        static::assertEquals([
            '1' => 'a',
            '2' => 1,
            '3' => true,
            '4' => ['a' => 'b'],
        ]$bag->all());

        static::assertEquals([
            '1' => 'a',
            '2' => 1,
            '3' => true,
            '4' => ['a' => 'b'],
        ]$bag->toRequestDataBag()->all());

        static::assertEquals([
            '1' => 'a',
            '2' => 1,
            
'description' => $description,
            'focus' => $focus,
        ]) {
            $formDataPart = new FormDataPart(array_filter([
                'file' => new DataPart($file),
                'thumbnail' => $thumbnail ? new DataPart($thumbnail) : null,
                'description' => $description,
                'focus' => $focus,
            ]));

            $headers = [];
            foreach ($formDataPart->getPreparedHeaders()->all() as $header) {
                $headers[] = $header->toString();
            }

            $responses[] = $this->request('POST', '/api/v2/media', [
                'headers' => $headers,
                'body' => $formDataPart->bodyToIterable(),
            ]);
        }

        $mediaIds = [];

        
static::assertFalse($eventCalled, 'Event was fired.');
        static::assertStringContainsString('Demo data command should only be used in production environment.', $tester->getDisplay());
        static::assertSame(Command::INVALID, $tester->getStatusCode());
    }

    public function testRequestHasDefaults(): void
    {
        $eventCalled = false;
        $this->dispatcher->addListener(DemodataRequestCreatedEvent::classstatic function DDemodataRequestCreatedEvent $event) use (&$eventCalled): void {
            $eventCalled = true;

            $items = $event->getRequest()->all();
            static::assertIsArray($items);

            foreach (self::DEFAULT_DEFINITIONS as $definition) {
                static::assertArrayHasKey($definition$items);
            }
        });

        $tester = new CommandTester($this->command);
        $tester->execute([]);

        static::assertTrue($eventCalled, 'Event was not fired.');
        

    private function validateHash(DataBag $data, SalesChannelContext $context): void
    {
        $definition = new DataValidationDefinition('customer.recovery.get');

        $hashLength = 32;

        $definition->add('hash', new NotBlank()new Type('string')new Length($hashLength));

        $this->dispatchValidationEvent($definition$data$context->getContext());

        $this->validator->validate($data->all()$definition);
    }

    private function dispatchValidationEvent(DataValidationDefinition $definition, DataBag $data, Context $context): void
    {
        $validationEvent = new BuildValidationEvent($definition$data$context);
        $this->eventDispatcher->dispatch($validationEvent$validationEvent->getName());
    }

    private function isExpired(CustomerRecoveryEntity $customerRecovery): bool
    {
        $validDateTime = (new \DateTime())->sub(new \DateInterval('PT2H'));

        
Home | Imprint | This part of the site doesn't use cookies.