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

Breadcrumb

  1. Drupal Core 11.1.x
  2. AbstractNormalizer.php

function AbstractNormalizer::validateCallbackContext

Validate callbacks set in context.

Parameters

string $contextType Used to specify which context is invalid in exceptions:

Throws

InvalidArgumentException

3 calls to AbstractNormalizer::validateCallbackContext()
AbstractNormalizer::__construct in vendor/symfony/serializer/Normalizer/AbstractNormalizer.php
Sets the {@link ClassMetadataFactoryInterface} to use.
AbstractObjectNormalizer::denormalize in vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php
Denormalizes data back into an object of the given class.
AbstractObjectNormalizer::normalize in vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php
Normalizes data into a set of arrays/scalars.

File

vendor/symfony/serializer/Normalizer/AbstractNormalizer.php, line 510

Class

AbstractNormalizer
Normalizer implementation.

Namespace

Symfony\Component\Serializer\Normalizer

Code

protected final function validateCallbackContext(array $context, string $contextType = '') : void {
    if (!isset($context[self::CALLBACKS])) {
        return;
    }
    if (!\is_array($context[self::CALLBACKS])) {
        throw new InvalidArgumentException(\sprintf('The "%s"%s context option must be an array of callables.', self::CALLBACKS, '' !== $contextType ? " {$contextType}" : ''));
    }
    foreach ($context[self::CALLBACKS] as $attribute => $callback) {
        if (!\is_callable($callback)) {
            throw new InvalidArgumentException(\sprintf('Invalid callback found for attribute "%s" in the "%s"%s context option.', $attribute, self::CALLBACKS, '' !== $contextType ? " {$contextType}" : ''));
        }
    }
}

API Navigation

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