Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3352256
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3352256
Merge requests
!16
Issue
#3365714
: move code out of sdc.module
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Issue
#3365714
: move code out of sdc.module
issue/drupal-3365714:3365714-move-sdc-sdc.module
into
3352256-meta-move-code
Overview
14
Commits
6
Pipelines
6
Changes
6
Merged
Issue #3365714: move code out of sdc.module
Mateu Aguiló Bosch
requested to merge
issue/drupal-3365714:3365714-move-sdc-sdc.module
into
3352256-meta-move-code
Dec 1, 2023
Overview
14
Commits
6
Pipelines
6
Changes
6
Closes
#3365714
0
0
Merge request reports
Compare
3352256-meta-move-code
version 5
8d816a2f
Dec 5, 2023
version 4
a0f7b998
Dec 4, 2023
version 3
c9bcd183
Dec 4, 2023
version 2
aeba2aeb
Dec 1, 2023
version 1
2c610296
Dec 1, 2023
3352256-meta-move-code (base)
and
latest version
latest version
ff0977de
6 commits,
Dec 5, 2023
version 5
8d816a2f
5 commits,
Dec 5, 2023
version 4
a0f7b998
4 commits,
Dec 4, 2023
version 3
c9bcd183
3 commits,
Dec 4, 2023
version 2
aeba2aeb
2 commits,
Dec 1, 2023
version 1
2c610296
2 commits,
Dec 1, 2023
6 files
+
80
−
68
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
+
54
−
2
View file @ ff0977de
Edit in single-file editor
Open in Web IDE
Show full file
@@ -12,7 +12,9 @@
use
Drupal\Core\Extension\ModuleHandlerInterface
;
use
Drupal\Core\Serialization\Yaml
;
use
Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
;
use
Drupal\Core\Theme\ComponentPluginManager
;
use
Drupal\Core\Theme\ThemeManagerInterface
;
use
Drupal\sdc\Plugin\Component
;
/**
* Parses library files to get extension data.
@@ -355,12 +357,14 @@ public function buildByExtension($extension) {
* Thrown when a parser exception got thrown.
*/
protected
function
parseLibraryInfo
(
$extension
,
$path
)
{
$libraries
=
[];
$libraries
=
$extension
===
'core'
?
$this
->
librariesForComponents
()
:
[];
$library_file
=
$path
.
'/'
.
$extension
.
'.libraries.yml'
;
if
(
file_exists
(
$this
->
root
.
'/'
.
$library_file
))
{
try
{
$libraries
=
Yaml
::
decode
(
file_get_contents
(
$this
->
root
.
'/'
.
$library_file
))
??
[];
$libraries
+
=
Yaml
::
decode
(
file_get_contents
(
$this
->
root
.
'/'
.
$library_file
))
??
[];
}
catch
(
InvalidDataTypeException
$e
)
{
// Rethrow a more helpful exception to provide context.
@@ -381,6 +385,54 @@ protected function parseLibraryInfo($extension, $path) {
return
$libraries
;
}
/**
* Builds the dynamic library definitions for single directory components.
*
* @return array
* The core library definitions for Single Directory Components.
*/
protected
function
librariesForComponents
():
array
{
// Iterate over all the components to get the CSS and JS files.
$components
=
$this
->
componentPluginManager
()
->
getAllComponents
();
$libraries
=
array_reduce
(
$components
,
static
function
(
array
$libraries
,
Component
$component
)
{
$library
=
$component
->
library
;
if
(
empty
(
$library
))
{
return
$libraries
;
}
$library_name
=
$component
->
getLibraryName
();
[,
$library_id
]
=
explode
(
'/'
,
$library_name
);
return
array_merge
(
$libraries
,
[
$library_id
=>
$library
]);
},
[]
);
$libraries
[
'components.all'
]
=
[
'dependencies'
=>
array_map
(
static
fn
(
Component
$component
)
=>
$component
->
getLibraryName
(),
$components
),
];
return
$libraries
;
}
/**
* Get the component plugin manager.
*
* The library discovery parser is a public service, and we cannot alter the
* constructor signature to inject this dependency without breaking backwards
* compatibility in Drupal 10.
*
* @return \Drupal\Core\Theme\ComponentPluginManager
* The component plugin manager.
*/
private
function
componentPluginManager
():
ComponentPluginManager
{
if
(
!
isset
(
$this
->
componentPluginManager
))
{
$this
->
componentPluginManager
=
\Drupal
::
service
(
'plugin.manager.sdc'
);
}
return
$this
->
componentPluginManager
;
}
/**
* Apply libraries overrides specified for the current active theme.
*
Loading