diff --git a/core/modules/serialization/lib/Drupal/serialization/RegisterSerializationClassesPass.php b/core/modules/serialization/lib/Drupal/serialization/RegisterSerializationClassesPass.php index 15b1e1b..b7ad9d8 100644 --- a/core/modules/serialization/lib/Drupal/serialization/RegisterSerializationClassesPass.php +++ b/core/modules/serialization/lib/Drupal/serialization/RegisterSerializationClassesPass.php @@ -12,12 +12,12 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** - * Adds servies tagged 'nested_matcher' services to the tagged_matcher service. + * Adds services tagged 'normalizer' and 'encoder' to the Serializer. */ class RegisterSerializationClassesPass implements CompilerPassInterface { /** - * Adds services tagged with normalizer or encoder to the Serializer. + * Adds services to the Serializer. * * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container * The container to process. @@ -49,17 +49,18 @@ public function process(ContainerBuilder $container) { * * The highest priority number is the highest priority (reverse sorting). * - * @param array $array + * @param array $services * A nested array of Normalizers/Encoders. * * @return array * An array of Normalizers/Encoders to be used by Serializer. */ - protected function sort($array) { + protected function sort($services) { $sorted = array(); - krsort($array); + krsort($services); - foreach ($array as $a) { + // Flatten the array. + foreach ($services as $a) { $sorted = array_merge($sorted, $a); } diff --git a/core/modules/serialization/lib/Drupal/serialization/SerializationBundle.php b/core/modules/serialization/lib/Drupal/serialization/SerializationBundle.php index 346ac95..4ccab45 100644 --- a/core/modules/serialization/lib/Drupal/serialization/SerializationBundle.php +++ b/core/modules/serialization/lib/Drupal/serialization/SerializationBundle.php @@ -20,6 +20,8 @@ class SerializationBundle extends Bundle { * Overrides Symfony\Component\HttpKernel\Bundle\Bundle::build(). */ public function build(ContainerBuilder $container) { + // Add Serializer with empty array arguments, which will be replaced in the + // compiler pass. $container->register('serializer', 'Symfony\Component\Serializer\Serializer') ->addArgument(array()) ->addArgument(array()); diff --git a/core/modules/serialization/tests/modules/serilization_test/lib/Drupal/serialization_test/SerializationTestEncoder.php b/core/modules/serialization/tests/modules/serilization_test/lib/Drupal/serialization_test/SerializationTestEncoder.php index a367c65..097bec0 100644 --- a/core/modules/serialization/tests/modules/serilization_test/lib/Drupal/serialization_test/SerializationTestEncoder.php +++ b/core/modules/serialization/tests/modules/serilization_test/lib/Drupal/serialization_test/SerializationTestEncoder.php @@ -10,6 +10,7 @@ use Symfony\Component\Serializer\Encoder\EncoderInterface; class SerializationTestEncoder implements EncoderInterface { + /** * The format that this Encoder supports. * @@ -21,9 +22,9 @@ class SerializationTestEncoder implements EncoderInterface { * Implementation required. This function not used for testing. * * @param mixed $data - * Data to encode + * Data to encode. * @param string $format - * Format name + * Format name. */ public function encode($data, $format) { } diff --git a/core/modules/serialization/tests/modules/serilization_test/lib/Drupal/serialization_test/SerializationTestNormalizer.php b/core/modules/serialization/tests/modules/serilization_test/lib/Drupal/serialization_test/SerializationTestNormalizer.php index 8000d40..01f31bc 100644 --- a/core/modules/serialization/tests/modules/serilization_test/lib/Drupal/serialization_test/SerializationTestNormalizer.php +++ b/core/modules/serialization/tests/modules/serilization_test/lib/Drupal/serialization_test/SerializationTestNormalizer.php @@ -10,6 +10,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class SerializationTestNormalizer implements NormalizerInterface { + /** * The format that this Normalizer supports. * @@ -33,7 +34,7 @@ public function normalize($object, $format = NULL) { } /** - * Checks whether the data and format are supported by this normalizer. + * Checks whether format is supported by this normalizer. * * @param mixed $data * Data to normalize. @@ -44,7 +45,6 @@ public function normalize($object, $format = NULL) { * Returns TRUE if the normalizer can handle the request. */ public function supportsNormalization($data, $format = NULL) { - // If this is an Entity object and the request is for JSON-LD. return static::$format === $format; } }