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

Breadcrumb

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

function Traverser::addFunction

Adds a function that will be called for each node in the tree. The function will receive the current node as argument. The action that will be executed on the node by the traverser depends on the returned value of the function:

  • a node: it will replace the node with the returned one
  • a numeric value that is a combination of the constants defined in this class: it will execute the function related to each constant
  • an array where the first element is a node and the second element is a numeric value that is a combination of the constants defined in this class: it will replace the node with the returned one and it will execute the function related to each constant (REMOVE_NODE will be ignored since it does not make any sense in this case)
  • other: nothing

Parameters

callable $fn Function to add:

Return value

$this

File

vendor/mck89/peast/lib/Peast/Traverser.php, line 95

Class

Traverser
Nodes traverser class

Namespace

Peast

Code

public function addFunction(callable $fn) {
    $this->functions[] = $fn;
    return $this;
}

API Navigation

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