You are here

function _auto_nodetitle_patternprocessor in Automatic Nodetitles 8

Same name and namespace in other branches
  1. 5 auto_nodetitle.module \_auto_nodetitle_patternprocessor()
  2. 6 auto_nodetitle.module \_auto_nodetitle_patternprocessor()
  3. 7 auto_nodetitle.module \_auto_nodetitle_patternprocessor()

Helper function to generate the title according to the settings.

Return value

a title string

1 call to _auto_nodetitle_patternprocessor()
auto_nodetitle_set_title in ./auto_nodetitle.module
Sets the automatically generated nodetitle for the node

File

./auto_nodetitle.module, line 137
Allows hiding of the node title field and automatic title creation.

Code

function _auto_nodetitle_patternprocessor($pattern, $node) {

  // Replace tokens.
  $token = Drupal::token();
  $output = $token
    ->replace($pattern, array(
    'node' => $node,
  ), array(
    'sanitize' => FALSE,
    'clear' => TRUE,
  ));

  // Evalute PHP.
  if (\Drupal::config('auto_nodetitle.node.' . $node
    ->getType())
    ->get('php')) {
    $output = auto_nodetitle_eval($output, $node);
  }

  // Strip tags.
  $output = preg_replace('/[\\t\\n\\r\\0\\x0B]/', '', strip_tags($output));
  return $output;
}