You are here

class MenuLinkNormalizer in Menu Normalizer 8

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

MenuLinkTreeElement Normalizer.

Hierarchy

Expanded class hierarchy of MenuLinkNormalizer

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

File

src/Normalizer/MenuLinkNormalizer.php, line 10

Namespace

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

  /**
   * {@inheritdoc}
   */
  public function normalize($object, $format = NULL, array $context = array()) {
    return [
      'weight' => $object
        ->getWeight(),
      'title' => $object
        ->getTitle(),
      'description' => $object
        ->getDescription(),
      'menu_name' => $object
        ->getMenuName(),
      'provider' => $object
        ->getProvider(),
      'parent' => $object
        ->getParent(),
      'enabled' => $object
        ->isEnabled(),
      'expanded' => $object
        ->isExpanded(),
      'resettable' => $object
        ->isResettable(),
      'translatable' => $object
        ->isTranslatable(),
      'deletable' => $object
        ->isDeletable(),
      'route_name' => $object
        ->getRouteName(),
      'route_parameters' => $object
        ->getRouteParameters(),
      'url' => $object
        ->getUrlObject()
        ->toString(),
      'options' => $object
        ->getOptions(),
      'meta_data' => $this->serializer
        ->normalize($object
        ->getMetaData(), $format, $context),
      'delete_route' => $object
        ->getDeleteRoute(),
      'edit_route' => $object
        ->getEditRoute(),
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY constant Name of key for bubbling cacheability metadata via serialization context.
MenuLinkNormalizer::$supportedInterfaceOrClass protected property The interface or class that this Normalizer supports. Overrides NormalizerBase::$supportedInterfaceOrClass
MenuLinkNormalizer::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