/** * {@inheritdoc} */ 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(); }
/** * {@inheritdoc} */ public function add(NodeInterface $node) { $fields = ['file' => $node->getFilename(), 'type' => get_class($node)]; if ($node instanceof ClassNode) { $fields['id'] = (string) $node->getName(); $fields['parent'] = (string) $node->getExtends(); } elseif ($node instanceof NewNode) { $fields['id'] = (string) $node->getClassName(); } else { throw new \InvalidArgumentException('Unexpected node type (expected ClassNode or NewNode).'); } $this->db->insert($this->table)->fields($fields)->execute(); }
/** * {@inheritdoc} */ public function add(NodeInterface $node) { if ($node instanceof DefineNode) { list($key, $value) = $node->getArguments(); if ($key instanceof StringNode && $value instanceof ScalarNode) { $this->elements[$key->toValue()] = $value->toValue(); } } elseif ($node instanceof ConstantDeclarationNode) { $value = $node->getValue(); if ($value instanceof ScalarNode) { $this->elements[(string) $node->getName()] = $value->toValue(); } } elseif ($node instanceof ConstantNode) { $this->db->insert($this->table)->fields(['id' => (string) $node->getConstantName(), 'file' => 'foo.module'])->execute(); } else { throw new \InvalidArgumentException('Unexpected node type (expected DefineNode, ConstantDeclarationNode, or ConstantNode).'); } }
/** * {@inheritdoc} */ public function add(NodeInterface $node) { $this->db->insert($this->table)->fields(['id' => (string) $node->getName(), 'file' => $node->getFilename()])->execute(); }