function Kernel::locateResource
Overrides KernelInterface::locateResource
File
-
vendor/
symfony/ http-kernel/ Kernel.php, line 210
Class
- Kernel
- The Kernel is the heart of the Symfony system.
Namespace
Symfony\Component\HttpKernelCode
public function locateResource(string $name) : string {
if ('@' !== $name[0]) {
throw new \InvalidArgumentException(\sprintf('A resource name must start with @ ("%s" given).', $name));
}
if (str_contains($name, '..')) {
throw new \RuntimeException(\sprintf('File name "%s" contains invalid characters (..).', $name));
}
$bundleName = substr($name, 1);
$path = '';
if (str_contains($bundleName, '/')) {
[
$bundleName,
$path,
] = explode('/', $bundleName, 2);
}
$bundle = $this->getBundle($bundleName);
if (file_exists($file = $bundle->getPath() . '/' . $path)) {
return $file;
}
throw new \InvalidArgumentException(\sprintf('Unable to find file "%s".', $name));
}