You are here

class MenuLinkTreeNormalizer in Menu Normalizer 2.x

Same name and namespace in other branches
  1. 8 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 {

  /**
   * Supported Interface or Class.
   *
   * @var string
   */
  protected $supportedInterfaceOrClass = 'Drupal\\Core\\Menu\\MenuLinkTreeElement';

  /**
   * {@inheritdoc}
   */
  public function normalize($object, $format = NULL, array $context = []) {
    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 Supported Interface or Class. Overrides NormalizerBase::$supportedInterfaceOrClass
MenuLinkTreeNormalizer::normalize public function
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. 1
NormalizerBase::supportsDenormalization public function Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() 1
NormalizerBase::supportsNormalization public function 1