function TestExecutableFinder::find

File

core/modules/package_manager/tests/modules/package_manager_test_validation/src/TestExecutableFinder.php, line 35

Class

TestExecutableFinder
A test-only executable finder that can be rigged to throw an exception.

Namespace

Drupal\package_manager_test_validation

Code

public function find(string $name) : string {
  $should_throw = \Drupal::keyValue('package_manager_test.executable_errors')->get($name);
  if ($should_throw) {
    throw new LogicException(new class  implements TranslatableInterface {
      
      /**
       * {@inheritdoc}
       */
      public function trans(?TranslatorInterface $translator = NULL, ?string $locale = NULL) : string {
        return 'Not found!';
      }
      
      /**
       * {@inheritdoc}
       */
      public function __toString() : string {
        return $this->trans();
      }

});
  }
  return $this->decorated
    ->find($name);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.