|
6 | 6 | use Drupal\Core\DependencyInjection\ContainerNotInitializedException;
|
7 | 7 | use Drupal\Core\DrupalKernelInterface;
|
8 | 8 | use Drupal\TestTools\PhpUnitCompatibility\PhpUnit8\ClassWriter;
|
9 |
| -use DrupalFinder\DrupalFinder; |
| 9 | +use DrupalFinder\DrupalFinderComposerRuntime; |
10 | 10 | use Drush\Drush;
|
11 | 11 | use PHPStan\DependencyInjection\Container;
|
12 | 12 | use PHPUnit\Framework\Test;
|
|
26 | 26 | use function is_array;
|
27 | 27 | use function is_dir;
|
28 | 28 | use function is_string;
|
29 |
| -use function realpath; |
30 | 29 | use function str_replace;
|
31 | 30 | use function strpos;
|
32 | 31 | use function strtr;
|
@@ -84,19 +83,21 @@ class DrupalAutoloader
|
84 | 83 | public function register(Container $container): void
|
85 | 84 | {
|
86 | 85 | /**
|
87 |
| - * @var array{drupal_root: string, bleedingEdge: array{checkDeprecatedHooksInApiFiles: bool, checkCoreDeprecatedHooksInApiFiles: bool, checkContribDeprecatedHooksInApiFiles: bool}} $drupalParams |
| 86 | + * @var array{drupal_root: string|null, bleedingEdge: array{checkDeprecatedHooksInApiFiles: bool, checkCoreDeprecatedHooksInApiFiles: bool, checkContribDeprecatedHooksInApiFiles: bool}} $drupalParams |
88 | 87 | */
|
89 | 88 | $drupalParams = $container->getParameter('drupal');
|
90 |
| - $drupalRoot = realpath($drupalParams['drupal_root']); |
91 |
| - $finder = new DrupalFinder(); |
92 |
| - $finder->locateRoot($drupalRoot); |
93 | 89 |
|
| 90 | + // Trigger deprecation error if drupal_root is used. |
| 91 | + if (is_string($drupalParams['drupal_root'])) { |
| 92 | + trigger_error('The drupal_root parameter is deprecated. Remove it from your configuration. Drupal Root is discoverd automatically.', E_USER_DEPRECATED); |
| 93 | + } |
| 94 | + |
| 95 | + $finder = new DrupalFinderComposerRuntime(); |
94 | 96 | $drupalRoot = $finder->getDrupalRoot();
|
95 | 97 | $drupalVendorRoot = $finder->getVendorDir();
|
96 | 98 | if (!(is_string($drupalRoot) && is_string($drupalVendorRoot))) {
|
97 |
| - throw new RuntimeException("Unable to detect Drupal at {$drupalParams['drupal_root']}"); |
| 99 | + throw new RuntimeException("Unable to detect Drupal with webflo/drupal-finder."); |
98 | 100 | }
|
99 |
| - |
100 | 101 | $this->drupalRoot = $drupalRoot;
|
101 | 102 |
|
102 | 103 | $this->autoloader = include $drupalVendorRoot . '/autoload.php';
|
|
0 commit comments