Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MenuLinkTreeElement.php

function MenuLinkTreeElement::count

Counts all menu links in the current subtree.

Return value

int The number of menu links in this subtree (one plus the number of menu links in all descendants).

File

core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php, line 118

Class

MenuLinkTreeElement
Provides a value object to model an element in a menu link tree.

Namespace

Drupal\Core\Menu

Code

public function count() {
    $sum = function ($carry, MenuLinkTreeElement $element) {
        return $carry + $element->count();
    };
    return 1 + array_reduce($this->subtree, $sum);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal