X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FIndexer%2FFunctionCalls.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FIndexer%2FFunctionCalls.php;h=cc5ac7821cc850794b9c650fe1235664f30f9280;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Indexer/FunctionCalls.php b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Indexer/FunctionCalls.php new file mode 100644 index 000000000..cc5ac7821 --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Indexer/FunctionCalls.php @@ -0,0 +1,69 @@ +target->getFinder() as $file) { + $path = $file->getPathname(); + + $this->target + ->open($path) + ->find(Filter::isInstanceOf('\Pharborist\Functions\FunctionCallNode')) + ->not(function(FunctionCallNode $function_call) { + return in_array($function_call->getName()->getText(), $this->pluginDefinition['exclude']); + }) + ->each([ $this, 'add' ]); + } + } + + /** + * {@inheritdoc} + */ + public function get($id) { + $all = new NodeCollection([]); + + $files = $this + ->getQuery(['file']) + ->distinct(TRUE) + ->condition('id', $id) + ->execute() + ->fetchCol(); + + array_walk($files, function($file) use ($all, $id) { + $all->add($this->target->open($file)->find(Filter::isFunctionCall($id))); + }); + + return $all; + } + + /** + * {@inheritdoc} + */ + public function addFile($path) { + $doc = Parser::parseFile($path); + + $doc + ->find(Filter::isInstanceOf('\Pharborist\Functions\FunctionCallNode')) + ->each([ $this, 'add' ]); + } + +}