Commit 2c7f56dd authored by Dries's avatar Dries
Browse files

Issue #1850704 by klausi, damiankloip: available serialization formats.

parent 0975b1fb
......@@ -253,8 +253,11 @@ public function build(ContainerBuilder $container) {
$container->register('serializer.normalizer.complex_data', 'Drupal\Core\Serialization\ComplexDataNormalizer')->addTag('normalizer');
$container->register('serializer.normalizer.list', 'Drupal\Core\Serialization\ListNormalizer')->addTag('normalizer');
$container->register('serializer.normalizer.typed_data', 'Drupal\Core\Serialization\TypedDataNormalizer')->addTag('normalizer');
$container->register('serializer.encoder.json', 'Drupal\Core\Serialization\JsonEncoder')->addTag('encoder');
$container->register('serializer.encoder.xml', 'Drupal\Core\Serialization\XmlEncoder')->addTag('encoder');
$container->register('serializer.encoder.json', 'Drupal\Core\Serialization\JsonEncoder')
->addTag('encoder', array('format' => array('json' => 'JSON')));
$container->register('serializer.encoder.xml', 'Drupal\Core\Serialization\XmlEncoder')
->addTag('encoder', array('format' => array('xml' => 'XML')));
$container->register('flood', 'Drupal\Core\Flood\DatabaseBackend')
->addArgument(new Reference('database'));
......
......@@ -42,6 +42,15 @@ public function process(ContainerBuilder $container) {
if (!empty($encoders)) {
$definition->replaceArgument(1, $this->sort($encoders));
}
// Find all serialization formats known.
$formats = array();
foreach ($container->findTaggedServiceIds('encoder') as $id => $attributes) {
foreach ($attributes[0]['format'] as $name => $label) {
$formats[$name] = $label;
}
}
$container->setParameter('serializer.formats', $formats);
}
/**
......
......@@ -58,7 +58,13 @@ public function build(ContainerBuilder $container) {
// Add the encoder to the service container. Encoders can only specify which
// format they support in Encoder::supportsEncoding().
$container->register('serializer.encoder.jsonld', 'Drupal\jsonld\JsonldEncoder')
->addTag('encoder', array('priority' => $priority));
->addTag('encoder', array(
'priority' => $priority,
'format' => array(
'jsonld' => 'JSON-LD',
'drupal_jsonld' => 'Drupal JSON-LD',
),
));
$container->register('jsonld.subscriber', 'Drupal\jsonld\EventSubscriber\JsonldSubscriber')
->addTag('event_subscriber');
......
......@@ -21,6 +21,7 @@ class SerializationTestBundle extends Bundle {
*/
public function build(ContainerBuilder $container) {
$container->register('serializer.normalizer.serialization_test', 'Drupal\serialization_test\SerializationTestNormalizer')->addTag('normalizer');
$container->register('serializer.encoder.serialization_test', 'Drupal\serialization_test\SerializationTestEncoder')->addTag('encoder');
$container->register('serializer.encoder.serialization_test', 'Drupal\serialization_test\SerializationTestEncoder')
->addTag('encoder', array('format' => array('serialization_test' => 'Serialization test')));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment