Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

Context.php

Same filename in this branch
  1. 11.1.x vendor/open-telemetry/api/Instrumentation/AutoInstrumentation/Context.php
  2. 11.1.x vendor/open-telemetry/context/Context.php
  3. 11.1.x vendor/sebastian/recursion-context/src/Context.php
  4. 11.1.x vendor/symfony/serializer/Annotation/Context.php
  5. 11.1.x vendor/phpdocumentor/type-resolver/src/Types/Context.php
  6. 11.1.x core/lib/Drupal/Core/Plugin/Context/Context.php
  7. 11.1.x core/lib/Drupal/Component/Plugin/Context/Context.php

Namespace

Symfony\Component\Serializer\Attribute

File

vendor/symfony/serializer/Attribute/Context.php

View source
<?php


/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Symfony\Component\Serializer\Attribute;

use Symfony\Component\Serializer\Exception\InvalidArgumentException;

/**
 * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
 */
class Context {
    private array $groups;
    
    /**
     * @param array<string, mixed> $context                The common context to use when serializing or deserializing
     * @param array<string, mixed> $normalizationContext   The context to use when serializing
     * @param array<string, mixed> $denormalizationContext The context to use when deserializing
     * @param string|string[]      $groups                 The groups to use when serializing or deserializing
     *
     * @throws InvalidArgumentException
     */
    public function __construct(array $context = [], array $normalizationContext = [], array $denormalizationContext = [], string|array $groups = []) {
        if (!$context && !$normalizationContext && !$denormalizationContext) {
            throw new InvalidArgumentException(\sprintf('At least one of the "context", "normalizationContext", or "denormalizationContext" options must be provided as a non-empty array to "%s".', static::class));
        }
        $this->groups = (array) $groups;
        foreach ($this->groups as $group) {
            if (!\is_string($group)) {
                throw new InvalidArgumentException(\sprintf('Parameter "groups" given to "%s" must be a string or an array of strings, "%s" given.', static::class, get_debug_type($group)));
            }
        }
    }
    public function getContext() : array {
        return $this->context;
    }
    public function getNormalizationContext() : array {
        return $this->normalizationContext;
    }
    public function getDenormalizationContext() : array {
        return $this->denormalizationContext;
    }
    public function getGroups() : array {
        return $this->groups;
    }

}
if (!class_exists(\Symfony\Component\Serializer\Annotation\Context::class, false)) {
    class_alias(Context::class, \Symfony\Component\Serializer\Annotation\Context::class);
}

Classes

Title Deprecated Summary
Context @author Maxime Steinhausser <maxime.steinhausser@gmail.com>

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal