You are here

private function FactoryMapperTest::getFactoryClassNamesFromFilesystem in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/preprocess_event_dispatcher/tests/src/Unit/FactoryMapperTest.php \Drupal\Tests\preprocess_event_dispatcher\Unit\FactoryMapperTest::getFactoryClassNamesFromFilesystem()

Get the Factory class names from the filesystems directory.

Return value

array Class names array.

1 call to FactoryMapperTest::getFactoryClassNamesFromFilesystem()
FactoryMapperTest::testYamlHasAllFactories in modules/preprocess_event_dispatcher/tests/src/Unit/FactoryMapperTest.php
Test if all factories are in the YAML file.

File

modules/preprocess_event_dispatcher/tests/src/Unit/FactoryMapperTest.php, line 55

Class

FactoryMapperTest
Class FactoryMapperTest.

Namespace

Drupal\Tests\preprocess_event_dispatcher\Unit

Code

private function getFactoryClassNamesFromFilesystem() : array {
  $files = scandir(dirname(__DIR__, 3) . '/src/Factory', SCANDIR_SORT_NONE);
  $invalidFactories = [
    '.',
    '..',
    'PreprocessEventFactoryInterface.php',
  ];
  $files = array_filter($files, static function ($file) use ($invalidFactories) {
    return !in_array($file, $invalidFactories, TRUE);
  });
  $classNames = [];
  foreach ($files as $file) {
    $classNames[] = 'Drupal\\preprocess_event_dispatcher\\Factory\\' . substr($file, 0, -4);
  }
  return $classNames;
}