You are here

public function RemoveJsonapiFormatCompilerPass::process in JSON:API 8

Updates the 'serializer.formats' container parameter.

Parameters

\Symfony\Component\DependencyInjection\ContainerBuilder $container: The container to process.

File

src/DependencyInjection/Compiler/RemoveJsonapiFormatCompilerPass.php, line 41

Class

RemoveJsonapiFormatCompilerPass
Removes 'api_json' format from the 'serializer.formats' container parameter.

Namespace

Drupal\jsonapi\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  if ($container
    ->hasParameter('serializer.formats')) {
    $filtered_formats = array_filter($container
      ->getParameter('serializer.formats'), function ($format) {
      return $format !== 'api_json';
    });
    $container
      ->setParameter('serializer.formats', array_values($filtered_formats));
  }
}