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

Breadcrumb

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

function DrupalAutoloader::loadAndCatchErrors

1 call to DrupalAutoloader::loadAndCatchErrors()
DrupalAutoloader::register in vendor/mglaman/phpstan-drupal/src/Drupal/DrupalAutoloader.php

File

vendor/mglaman/phpstan-drupal/src/Drupal/DrupalAutoloader.php, line 359

Class

DrupalAutoloader

Namespace

mglaman\PHPStanDrupal\Drupal

Code

protected function loadAndCatchErrors(string $path) : void {
    try {
        require_once $path;
    } catch (ContainerNotInitializedException $e) {
        $path = str_replace(dirname($this->drupalRoot) . '/', '', $path);
        // This can happen when drupal_get_path or drupal_get_filename are used outside the scope of a function.
        @trigger_error("{$path} invoked the Drupal container outside of the scope of a function or class method. It was not loaded.", E_USER_WARNING);
    } catch (Throwable $e) {
        $path = str_replace(dirname($this->drupalRoot) . '/', '', $path);
        // Something prevented the extension file from loading.
        @trigger_error("{$path} failed loading due to {$e->getMessage()}", E_USER_WARNING);
    }
}

API Navigation

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