Skip to content
Snippets Groups Projects
Commit aed16572 authored by Samuel Mortenson's avatar Samuel Mortenson Committed by Damien McKenna
Browse files

By samuel.mortenson, Berdir, DamienMcKenna: Fix data property definition.

parent 4e75db63
No related branches found
Tags 7.x-1.0-beta3
No related merge requests found
Metatag 8.x-1.8, 2019-02-20
---------------------------
By samuel.mortenson, Berdir, DamienMcKenna: Fix data property definition.
Metatag 8.x-1.7, 2018-08-31
---------------------------
#2994979 by DamienMcKenna, dspachos, ynotpeanutbutter, oxy86, IT-Cru, kdeds,
......
......@@ -4,7 +4,6 @@ namespace Drupal\metatag;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Drupal\metatag\Normalizer\FieldItemNormalizer;
use Drupal\metatag\Normalizer\MetatagHalNormalizer;
use Drupal\metatag\Normalizer\MetatagNormalizer;
use Symfony\Component\DependencyInjection\Definition;
......@@ -30,10 +29,6 @@ class MetatagServiceProvider extends ServiceProviderBase {
$metatag_hal = new Definition(MetatagHalNormalizer::class);
$metatag_hal->addTag('normalizer', ['priority' => 31]);
$container->setDefinition('metatag.normalizer.metatag.hal', $metatag_hal);
$metatag_field = new Definition(FieldItemNormalizer::class);
$metatag_field->addTag('normalizer', ['priority' => 30]);
$container->setDefinition('metatag.normalizer.metatag_field', $metatag_field);
}
}
......
<?php
namespace Drupal\metatag\Normalizer;
use Drupal\serialization\Normalizer\NormalizerBase;
/**
* Converts the Metatag field item object structure to METATAG array structure.
*/
class FieldItemNormalizer extends NormalizerBase {
/**
* {@inheritdoc}
*/
protected $supportedInterfaceOrClass = 'Drupal\metatag\Plugin\Field\FieldType\MetatagFieldItem';
/**
* {@inheritdoc}
*/
public function normalize($field_item, $format = NULL, array $context = []) {
$values = $field_item->getValue();
$normalized['value'] = unserialize($values['value']);
return $normalized;
}
}
......@@ -19,7 +19,6 @@ class MetatagHalNormalizer extends MetatagNormalizer {
$normalized = parent::normalize($field_item, $format, $context);
// Mock the field array similar to the other fields.
// @see Drupal\hal\Normalizer\FieldItemNormalizer
return [
'metatag' => [$normalized],
];
......
......@@ -14,7 +14,10 @@ use Drupal\Core\TypedData\DataDefinition;
* label = @Translation("Meta tags"),
* description = @Translation("This field stores code meta tags."),
* default_widget = "metatag_firehose",
* default_formatter = "metatag_empty_formatter"
* default_formatter = "metatag_empty_formatter",
* serialized_property_names = {
* "value"
* }
* )
*/
class MetatagFieldItem extends FieldItemBase {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment