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

Breadcrumb

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

function ComponentLoader::isFresh

Overrides LoaderInterface::isFresh

File

core/lib/Drupal/Core/Template/Loader/ComponentLoader.php, line 117

Class

ComponentLoader
Lets you load templates using the component ID.

Namespace

Drupal\Core\Template\Loader

Code

public function isFresh(string $name, int $time) : bool {
    $file_is_fresh = static fn(string $path) => filemtime($path) < $time;
    try {
        $component = $this->pluginManager
            ->find($name);
    } catch (ComponentNotFoundException) {
        throw new LoaderError('Unable to find component');
    }
    // If any of the templates, or the component definition, are fresh. Then the
    // component is fresh.
    $metadata_path = $component->getPluginDefinition()[YamlDirectoryDiscovery::FILE_KEY];
    if ($file_is_fresh($metadata_path)) {
        return TRUE;
    }
    return $file_is_fresh($component->getTemplatePath());
}

API Navigation

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