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\LoaderCode
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());
}