LibraryDiscoveryParser need to check Theme exist similar to Module

Created on 9 February 2024, 4 months ago

Problem/Motivation

Non-existing attachment declarations in Twig file throwing Warning error.

    if ($extension === 'core') {
      $path = 'core';
      $extension_type = 'core';
    }
    else {
      if ($this->moduleHandler->moduleExists($extension)) {
        $extension_type = 'module';
      }
      else {
        $extension_type = 'theme';
      }
      $path = $this->extensionPathResolver->getPath($extension_type, $extension);
    }

If the given extension name does not exist in the Twig library, that is considered as Theme instead of checking whether the library extension exists.

Steps to reproduce

1. Create a custom Sample module(sample.module) in a fresh Drupal site.
2. Add hook_theme and create a custom render template.
3. Inside the TWIG attach non existing library as below.
{{ attach_library('xyz_module/xy_library') }}

Proposed resolution

As same as moduleExists() check need to implement for the $this->themeHandler->themeExists($extension)

Merge request link

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component
Asset library  →

Last updated 2 days ago

No maintainer
Created by

🇮🇳India arunkumark Coimbatore

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024