You are here

public function Functions::add in Drupal 7 to 8/9 Module Upgrader 8

Overrides IndexerBase::add

File

src/Plugin/DMU/Indexer/Functions.php, line 71

Class

Functions
Plugin annotation @Indexer( id = "function" )

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Indexer

Code

public function add(NodeInterface $node) {

  /** @var \Pharborist\Functions\FunctionDeclarationNode|\Pharborist\Functions\FunctionCallNode $node */
  $fields = [
    'id' => (string) $node
      ->getName(),
    'file' => $node
      ->getFilename(),
    'type' => get_class($node),
  ];
  if ($node instanceof FunctionDeclarationNode) {
    $logical = new ContainsLogicFilter();
    $logical
      ->whitelist('t');
    $logical
      ->whitelist('drupal_get_path');
    $fields['has_logic'] = (int) $node
      ->is($logical);
  }
  $this->db
    ->insert($this->table)
    ->fields($fields)
    ->execute();
}