Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
80554ebf
Commit
80554ebf
authored
Sep 01, 2016
by
catch
Browse files
Issue
#2720849
by joseph.olstad, quicksketch: D8 improve theme registry build performance
parent
b9aa30a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/includes/theme.inc
View file @
80554ebf
...
...
@@ -134,7 +134,7 @@ function drupal_theme_rebuild() {
*/
function
drupal_find_theme_functions
(
$cache
,
$prefixes
)
{
$implementations
=
[];
$grouped_functions
=
\
Drupal
::
service
(
'theme.registry'
)
->
getPrefixGroupedUserFunctions
();
$grouped_functions
=
\
Drupal
::
service
(
'theme.registry'
)
->
getPrefixGroupedUserFunctions
(
$prefixes
);
foreach
(
$cache
as
$hook
=>
$info
)
{
foreach
(
$prefixes
as
$prefix
)
{
...
...
core/lib/Drupal/Core/Theme/Registry.php
View file @
80554ebf
...
...
@@ -633,8 +633,6 @@ protected function completeSuggestion($hook, array &$cache) {
* @see ::processExtension()
*/
protected
function
postProcessExtension
(
array
&
$cache
,
ActiveTheme
$theme
)
{
$grouped_functions
=
$this
->
getPrefixGroupedUserFunctions
();
// Gather prefixes. This will be used to limit the found functions to the
// expected naming conventions.
$prefixes
=
array_keys
((
array
)
$this
->
moduleHandler
->
getModuleList
());
...
...
@@ -646,6 +644,8 @@ protected function postProcessExtension(array &$cache, ActiveTheme $theme) {
}
$prefixes
[]
=
$theme
->
getName
();
$grouped_functions
=
$this
->
getPrefixGroupedUserFunctions
(
$prefixes
);
// Collect all variable preprocess functions in the correct order.
$suggestion_level
=
[];
$matches
=
[];
...
...
@@ -744,15 +744,26 @@ public function destruct() {
/**
* Gets all user functions grouped by the word before the first underscore.
*
* @param $prefixes
* An array of function prefixes by which the list can be limited.
* @return array
* Functions grouped by the first prefix.
*/
public
function
getPrefixGroupedUserFunctions
()
{
public
function
getPrefixGroupedUserFunctions
(
$prefixes
=
array
()
)
{
$functions
=
get_defined_functions
();
// If a list of prefixes is supplied, trim down the list to those items
// only as efficiently as possible.
if
(
$prefixes
)
{
$theme_functions
=
preg_grep
(
'/^('
.
implode
(
')|('
,
$prefixes
)
.
')_/'
,
$functions
[
'user'
]);
}
else
{
$theme_functions
=
$functions
[
'user'
];
}
$grouped_functions
=
[];
// Splitting user defined functions into groups by the first prefix.
foreach
(
$functions
[
'user'
]
as
$function
)
{
foreach
(
$
theme_
functions
as
$function
)
{
list
(
$first_prefix
,)
=
explode
(
'_'
,
$function
,
2
);
$grouped_functions
[
$first_prefix
][]
=
$function
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment