Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContainerBuilder.php

function ContainerBuilder::fileExists

Checks whether the requested file or directory exists and registers the result for resource tracking.

@final

Parameters

string $path The file or directory path for which to check the existence:

bool|string $trackContents Whether to track contents of the given resource. If a string is passed,: it will be used as pattern for tracking contents of the requested directory

1 call to ContainerBuilder::fileExists()
ContainerBuilder::addObjectResource in vendor/symfony/dependency-injection/ContainerBuilder.php
Adds the object class hierarchy as resources.

File

vendor/symfony/dependency-injection/ContainerBuilder.php, line 438

Class

ContainerBuilder
ContainerBuilder is a DI container that provides an API to easily describe services.

Namespace

Symfony\Component\DependencyInjection

Code

public function fileExists(string $path, bool|string $trackContents = true) : bool {
    $exists = file_exists($path);
    if (!$this->trackResources || $this->inVendors($path)) {
        return $exists;
    }
    if (!$exists) {
        $this->addResource(new FileExistenceResource($path));
        return false;
    }
    if (is_dir($path)) {
        if ($trackContents) {
            $this->addResource(new DirectoryResource($path, \is_string($trackContents) ? $trackContents : null));
        }
        else {
            $this->addResource(new GlobResource($path, '/*', false));
        }
    }
    elseif ($trackContents) {
        $this->addResource(new FileResource($path));
    }
    return true;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal