You are here

class MenuLinkTreeNormalizer in Menu Normalizer 8

Same name and namespace in other branches
  1. 2.x src/Normalizer/MenuLinkTreeNormalizer.php \Drupal\menu_normalizer\Normalizer\MenuLinkTreeNormalizer

MenuLinkTreeElement Normalizer.

Hierarchy

Expanded class hierarchy of MenuLinkTreeNormalizer

1 string reference to 'MenuLinkTreeNormalizer'
menu_normalizer.services.yml in ./menu_normalizer.services.yml
menu_normalizer.services.yml
1 service uses MenuLinkTreeNormalizer
menu_normalizer.normalizer.menu_link_tree in ./menu_normalizer.services.yml
Drupal\menu_normalizer\Normalizer\MenuLinkTreeNormalizer

File

src/Normalizer/MenuLinkTreeNormalizer.php, line 10

Namespace

Drupal\menu_normalizer\Normalizer
View source
class MenuLinkTreeNormalizer extends NormalizerBase {
  protected $supportedInterfaceOrClass = 'Drupal\\Core\\Menu\\MenuLinkTreeElement';

  /**
   * {@inheritdoc}
   */
  public function normalize($object, $format = NULL, array $context = array()) {
    return [
      'link' => $this->serializer
        ->normalize($object->link, $format, $context),
      'has_children' => $object->hasChildren,
      'depth' => $object->depth,
      'in_active_trail' => $object->inActiveTrail,
      'subtree' => $this->serializer
        ->normalize($object->subtree, $format, $context),
      'count' => $object
        ->count(),
    ];
  }

}

Members

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