Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176

This commit is contained in:
Pantheon Automation 2015-08-17 17:00:26 -07:00 committed by Greg Anderson
commit 9921556621
13277 changed files with 1459781 additions and 0 deletions

View file

@ -0,0 +1,6 @@
name: Serialization test module
type: module
description: "Support module for serialization tests."
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,9 @@
services:
serializer.normalizer.serialization_test:
class: Drupal\serialization_test\SerializationTestNormalizer
tags:
- { name: normalizer }
serializer.encoder.serialization_test:
class: Drupal\serialization_test\SerializationTestEncoder
tags:
- { name: encoder, format: serialization_test}

View file

@ -0,0 +1,35 @@
<?php
/**
* @file
* Contains \Drupal\serialization_test\SerializationTestEncoder.
*/
namespace Drupal\serialization_test;
use Symfony\Component\Serializer\Encoder\EncoderInterface;
class SerializationTestEncoder implements EncoderInterface {
/**
* The format that this Encoder supports.
*
* @var string
*/
static protected $format = 'serialization_test';
/**
* Implements \Symfony\Component\Serializer\Encoder\EncoderInterface::encode().
*/
public function encode($data, $format, array $context = array()) {
// @see \Drupal\serialization_test\SerializationTestNormalizer::normalize().
return 'Normalized by ' . $data['normalized_by'] . ', Encoded by SerializationTestEncoder';
}
/**
* Implements \Symfony\Component\Serializer\Encoder\EncoderInterface::supportsEncoding().
*/
public function supportsEncoding($format) {
return static::$format === $format;
}
}

View file

@ -0,0 +1,55 @@
<?php
/**
* @file
* Contains \Drupal\serialization_test\SerializationTestNormalizer.
*/
namespace Drupal\serialization_test;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class SerializationTestNormalizer implements NormalizerInterface {
/**
* The format that this Normalizer supports.
*
* @var string
*/
static protected $format = 'serialization_test';
/**
* Normalizes an object into a set of arrays/scalars.
*
* @param object $object
* Object to normalize.
* @param string $format
* Format the normalization result will be encoded as.
*
* @return array
* An array containing a normalized representation of $object, appropriate
* for encoding to the requested format.
*/
public function normalize($object, $format = NULL, array $context = array()) {
$normalized = (array) $object;
// Add identifying value that can be used to verify that the expected
// normalizer was invoked.
$normalized['normalized_by'] = 'SerializationTestNormalizer';
return $normalized;
}
/**
* Checks whether format is supported by this normalizer.
*
* @param mixed $data
* Data to normalize.
* @param string $format
* Format the normalization result will be encoded as.
*
* @return bool
* Returns TRUE if the normalizer can handle the request.
*/
public function supportsNormalization($data, $format = NULL) {
return static::$format === $format;
}
}