Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[yaffs-website] / web / core / modules / serialization / src / Normalizer / TimestampItemNormalizer.php
1 <?php
2
3 namespace Drupal\serialization\Normalizer;
4
5 use Drupal\Core\Field\Plugin\Field\FieldType\TimestampItem;
6 use Symfony\Component\Serializer\Exception\InvalidArgumentException;
7
8 /**
9  * Converts values for TimestampItem to and from common formats.
10  */
11 class TimestampItemNormalizer extends FieldItemNormalizer {
12
13   use TimeStampItemNormalizerTrait;
14
15   /**
16    * The interface or class that this Normalizer supports.
17    *
18    * @var string
19    */
20   protected $supportedInterfaceOrClass = TimestampItem::class;
21
22   /**
23    * {@inheritdoc}
24    */
25   public function normalize($field_item, $format = NULL, array $context = []) {
26     $data = parent::normalize($field_item, $format, $context);
27
28     return $this->processNormalizedValues($data);
29   }
30
31   /**
32    * {@inheritdoc}
33    */
34   public function denormalize($data, $class, $format = NULL, array $context = []) {
35     if (empty($data['value'])) {
36       throw new InvalidArgumentException('No "value" attribute present');
37     }
38
39     return parent::denormalize($data, $class, $format, $context);
40   }
41
42 }