You are here

public function Classes::getUsages in Drupal 7 to 8/9 Module Upgrader 8

Overrides IndexerUsageInterface::getUsages

File

src/Plugin/DMU/Indexer/Classes.php, line 96

Class

Classes
Plugin annotation @Indexer( id = "class" )

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Indexer

Code

public function getUsages($identifier) {
  $files = $this
    ->getQuery([
    'file',
  ])
    ->distinct()
    ->condition('id', $identifier)
    ->condition('type', 'Pharborist\\Objects\\NewNode')
    ->execute()
    ->fetchCol();
  $usages = new NodeCollection();
  foreach ($files as $file) {
    $this->target
      ->open($file)
      ->find(Filter::isInstanceOf('\\Pharborist\\Objects\\NewNode'))
      ->filter(function (NewNode $node) use ($identifier) {
      return $node
        ->getClassName() == $identifier;
    })
      ->addTo($usages);
  }
  return $usages;
}