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
2ab81dbf
Commit
2ab81dbf
authored
Dec 22, 2014
by
webchick
Browse files
Issue
#2392717
by a_thakur, tadityar: Remove hook_library_alter() from theme.api.php
parent
5367cedb
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Asset/LibraryDiscovery.php
View file @
2ab81dbf
...
...
@@ -32,8 +32,8 @@ class LibraryDiscovery implements LibraryDiscoveryInterface {
/**
* The final library definitions, statically cached.
*
* hook_library_alter() a
llows modules and themes to dynamically alter a
* library definition (once per request).
* hook_library_
info_
alter() a
nd hook_js_settings_alter() allows modules
*
and themes to dynamically alter a
library definition (once per request).
*
* @var array
*/
...
...
core/modules/system/theme.api.php
View file @
2ab81dbf
...
...
@@ -787,39 +787,6 @@ function hook_library_info_alter(&$libraries, $module) {
}
}
/**
* Alters a JavaScript/CSS library before it is attached.
*
* Allows modules and themes to dynamically attach further assets to a library
* when it is added to the page; e.g., to add JavaScript settings.
*
* This hook is only invoked once per library and page.
*
* @param array $library
* The JavaScript/CSS library that is being added.
* @param string $name
* The name of the library.
*
* @see _drupal_add_library()
*
* @deprecated in Drupal 8.0.x, will be removed before Drupal 8.0.0
* Use hook_library_info_alter() and hook_js_settings_alter().
*/
function
hook_library_alter
(
array
&
$library
,
$name
)
{
if
(
$name
==
'core/jquery.ui.datepicker'
)
{
// Note: If the added assets do not depend on additional request-specific
// data supplied here, consider to statically register it directly via
// hook_library_info_alter() already.
$library
[
'dependencies'
][]
=
'locale/drupal.locale.datepicker'
;
$language_interface
=
\
Drupal
::
languageManager
()
->
getCurrentLanguage
();
$library
[
'drupalSettings'
][
'jquery'
][
'ui'
][
'datepicker'
]
=
array
(
'isRTL'
=>
$language_interface
->
getDirection
()
==
LanguageInterface
::
DIRECTION_RTL
,
'firstDay'
=>
\
Drupal
::
config
(
'system.date'
)
->
get
(
'first_day'
),
);
}
}
/**
* Alter CSS files before they are output on the page.
*
...
...
core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryTest.php
View file @
2ab81dbf
...
...
@@ -87,10 +87,11 @@ public function testGetLibrariesByExtension() {
);
$this
->
libraryDiscovery
->
getLibrariesbyExtension
(
'test'
);
// Verify that subsequent calls don't trigger hook_library_alter()
// invocations, nor do they talk to the collector again. This ensures that
// the alterations made by hook_library_alter() implementations are
// statically cached, as desired.
// Verify that subsequent calls don't trigger hook_library_info_alter()
// and hook_js_settings_alter() invocations, nor do they talk to the
// collector again. This ensures that the alterations made by
// hook_library_info_alter() and hook_js_settings_alter() implementations
// are statically cached, as desired.
$this
->
libraryDiscovery
->
getLibraryByName
(
'test'
,
'test_1'
);
$this
->
libraryDiscovery
->
getLibrariesbyExtension
(
'test'
);
}
...
...
Write
Preview
Markdown
is supported
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