Skip to content

Commit

Permalink
Use PathUtil to check if hook is in vendor dir
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jul 10, 2020
1 parent 4328f77 commit b5d4be1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core-bundle/src/DataCollector/ContaoDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Webmozart\PathUtil\Path;

/**
* @internal
Expand Down Expand Up @@ -187,13 +188,12 @@ private function addLegacyRoutingData(): void
$class = $systemAdapter->importStatic($callback[0]);
$r = new \ReflectionClass($class);
$file = $r->getFileName();
$base = $this->parameterBag->get('kernel.project_dir').'/vendor/';
$baseLength = \strlen($base);
$vendorDir = $this->parameterBag->get('kernel.project_dir').'/vendor/';

$hook = ['name' => $name, 'class' => \get_class($class), 'method' => $callback[1], 'package' => ''];

if (0 === strncmp($file, $base, $baseLength)) {
[$vendor, $package] = explode('/', substr($file, $baseLength), 3);
if (Path::isBasePath($vendorDir, $file)) {
[$vendor, $package] = explode('/', Path::makeRelative($file, $vendorDir), 3);
$hook['package'] = $vendor.'/'.$package;
}

Expand Down

0 comments on commit b5d4be1

Please sign in to comment.