function ContainerBuilder::addResource
Return value
$this
4 calls to ContainerBuilder::addResource()
- ContainerBuilder::fileExists in vendor/
symfony/ dependency-injection/ ContainerBuilder.php - Checks whether the requested file or directory exists and registers the result for resource tracking.
- ContainerBuilder::getReflectionClass in vendor/
symfony/ dependency-injection/ ContainerBuilder.php - Retrieves the requested reflection class and registers it for resource tracking.
- ContainerBuilder::inVendors in vendor/
symfony/ dependency-injection/ ContainerBuilder.php - ContainerBuilder::merge in vendor/
symfony/ dependency-injection/ ContainerBuilder.php - Merges a ContainerBuilder with the current ContainerBuilder configuration.
File
-
vendor/
symfony/ dependency-injection/ ContainerBuilder.php, line 258
Class
- ContainerBuilder
- ContainerBuilder is a DI container that provides an API to easily describe services.
Namespace
Symfony\Component\DependencyInjectionCode
public function addResource(ResourceInterface $resource) : static {
if (!$this->trackResources) {
return $this;
}
if ($resource instanceof GlobResource && $this->inVendors($resource->getPrefix())) {
return $this;
}
if ($resource instanceof FileExistenceResource && $this->inVendors($resource->getResource())) {
return $this;
}
if ($resource instanceof FileResource && $this->inVendors($resource->getResource())) {
return $this;
}
if ($resource instanceof DirectoryResource && $this->inVendors($resource->getResource())) {
return $this;
}
if ($resource instanceof ClassExistenceResource) {
$class = $resource->getResource();
$inVendor = false;
foreach (spl_autoload_functions() as $autoloader) {
if (!\is_array($autoloader)) {
continue;
}
if ($autoloader[0] instanceof DebugClassLoader) {
$autoloader = $autoloader[0]->getClassLoader();
}
if (!\is_array($autoloader) || !$autoloader[0] instanceof ClassLoader || !$autoloader[0]->findFile(__CLASS__)) {
continue;
}
foreach ($autoloader[0]->getPrefixesPsr4() as $prefix => $dirs) {
if ('' === $prefix || !str_starts_with($class, $prefix)) {
continue;
}
foreach ($dirs as $dir) {
if (!($dir = realpath($dir))) {
continue;
}
if (!($inVendor = $this->inVendors($dir))) {
break 3;
}
}
}
}
if ($inVendor) {
return $this;
}
}
$this->resources[(string) $resource] = $resource;
return $this;
}