You are here

class MetatagNormalizer in Replication 8

Normalizes metatag into the viewed entity.

Hierarchy

  • class \Drupal\serialization\Normalizer\NormalizerBase implements \Symfony\Component\Serializer\SerializerAwareInterface, CacheableNormalizerInterface uses \Symfony\Component\Serializer\SerializerAwareTrait
    • class \Drupal\serialization\Normalizer\ListNormalizer
      • class \Drupal\serialization\Normalizer\FieldNormalizer implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface

Expanded class hierarchy of MetatagNormalizer

1 string reference to 'MetatagNormalizer'
replication.services.yml in ./replication.services.yml
replication.services.yml
1 service uses MetatagNormalizer
replication.normalizer.metatag in ./replication.services.yml
Drupal\replication\Normalizer\MetatagNormalizer

File

src/Normalizer/MetatagNormalizer.php, line 10

Namespace

Drupal\replication\Normalizer
View source
class MetatagNormalizer extends FieldNormalizer {

  /**
   * {@inheritdoc}
   */
  protected $supportedInterfaceOrClass = 'Drupal\\metatag\\Plugin\\Field\\MetatagEntityFieldItemList';

  /**
   * @var string[]
   */
  protected $format = [
    'json',
  ];

  /**
   * {@inheritdoc}
   */
  public function normalize($field_item, $format = NULL, array $context = []) {
    $normalized = [];
    if (\Drupal::hasService('metatag.normalizer.metatag')) {
      $normalized = \Drupal::service('metatag.normalizer.metatag')
        ->normalize($field_item, $format, $context);
    }
    return [
      $normalized,
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function denormalize($data, $class, $format = NULL, array $context = []) {
    return parent::denormalize($data, $class, $format, $context);
  }

  /**
   * {@inheritdoc}
   */
  public function supportsDenormalization($data, $type, $format = NULL) {
    if (in_array($type, [
      'Drupal\\metatag\\Plugin\\Field\\MetatagEntityFieldItemList',
    ])) {
      return TRUE;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY constant Name of key for bubbling cacheability metadata via serialization context.
MetatagNormalizer::$format protected property Overrides NormalizerBase::$format
MetatagNormalizer::$supportedInterfaceOrClass protected property The interface or class that this Normalizer supports. Overrides FieldNormalizer::$supportedInterfaceOrClass
MetatagNormalizer::denormalize public function Denormalizes data back into an object of the given class. Overrides FieldNormalizer::denormalize
MetatagNormalizer::normalize public function Normalizes an object into a set of arrays/scalars. Overrides ListNormalizer::normalize
MetatagNormalizer::supportsDenormalization public function Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() Overrides NormalizerBase::supportsDenormalization
NormalizerBase::addCacheableDependency protected function Adds cacheability if applicable.
NormalizerBase::checkFormat protected function Checks if the provided format is supported by this normalizer. 2
NormalizerBase::supportsNormalization public function Checks whether the given class is supported for normalization by this normalizer. 1