You are here

public function MenuLinkContent::getPluginDefinition in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/menu_link_content/src/Entity/MenuLinkContent.php \Drupal\menu_link_content\Entity\MenuLinkContent::getPluginDefinition()

Builds up the menu link plugin definition for this entity.

Return value

array The plugin definition corresponding to this entity.

Overrides MenuLinkContentInterface::getPluginDefinition

See also

\Drupal\Core\Menu\MenuLinkTree::$defaults

1 call to MenuLinkContent::getPluginDefinition()
MenuLinkContent::postSave in core/modules/menu_link_content/src/Entity/MenuLinkContent.php
Acts on a saved entity before the insert or update hook is invoked.

File

core/modules/menu_link_content/src/Entity/MenuLinkContent.php, line 151

Class

MenuLinkContent
Defines the menu link content entity class.

Namespace

Drupal\menu_link_content\Entity

Code

public function getPluginDefinition() {
  $definition = [];
  $definition['class'] = 'Drupal\\menu_link_content\\Plugin\\Menu\\MenuLinkContent';
  $definition['menu_name'] = $this
    ->getMenuName();
  if ($url_object = $this
    ->getUrlObject()) {
    $definition['url'] = NULL;
    $definition['route_name'] = NULL;
    $definition['route_parameters'] = [];
    if (!$url_object
      ->isRouted()) {
      $definition['url'] = $url_object
        ->getUri();
    }
    else {
      $definition['route_name'] = $url_object
        ->getRouteName();
      $definition['route_parameters'] = $url_object
        ->getRouteParameters();
    }
    $definition['options'] = $url_object
      ->getOptions();
  }
  $definition['title'] = $this
    ->getTitle();
  $definition['description'] = $this
    ->getDescription();
  $definition['weight'] = $this
    ->getWeight();
  $definition['id'] = $this
    ->getPluginId();
  $definition['metadata'] = [
    'entity_id' => $this
      ->id(),
  ];
  $definition['form_class'] = '\\Drupal\\menu_link_content\\Form\\MenuLinkContentForm';
  $definition['enabled'] = $this
    ->isEnabled() ? 1 : 0;
  $definition['expanded'] = $this
    ->isExpanded() ? 1 : 0;
  $definition['provider'] = 'menu_link_content';
  $definition['discovered'] = 0;
  $definition['parent'] = $this
    ->getParentId();
  return $definition;
}