ApiPlatform\Core\Bridge\Symfony\Bundle\DependencyInjection\Configuration::addExceptionToStatusSection PHP Method

addExceptionToStatusSection() private method

Adds an exception to status section.
private addExceptionToStatusSection ( ArrayNodeDefinition $rootNode )
$rootNode Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition
    private function addExceptionToStatusSection(ArrayNodeDefinition $rootNode)
    {
        $rootNode->children()->arrayNode('exception_to_status')->defaultValue([ExceptionInterface::class => Response::HTTP_BAD_REQUEST, InvalidArgumentException::class => Response::HTTP_BAD_REQUEST])->info('The list of exceptions mapped to their HTTP status code.')->normalizeKeys(false)->useAttributeAsKey('exception_class')->beforeNormalization()->ifArray()->then(function (array $exceptionToStatus) {
            foreach ($exceptionToStatus as &$httpStatusCode) {
                if (is_int($httpStatusCode)) {
                    continue;
                }
                if (defined($httpStatusCodeConstant = sprintf('%s::%s', Response::class, $httpStatusCode))) {
                    $httpStatusCode = constant($httpStatusCodeConstant);
                }
            }
            return $exceptionToStatus;
        })->end()->prototype('integer')->end()->validate()->ifArray()->then(function (array $exceptionToStatus) {
            foreach ($exceptionToStatus as $httpStatusCode) {
                if ($httpStatusCode < 100 || $httpStatusCode >= 600) {
                    throw new InvalidConfigurationException(sprintf('The HTTP status code "%s" is not valid.', $httpStatusCode));
                }
            }
            return $exceptionToStatus;
        })->end()->end()->end();
    }