Commit 99d3490f authored by webchick's avatar webchick
Browse files

Issue #2168113 by penyaskito, jessebeach, catch: Add leading underscore and...

Issue #2168113 by penyaskito, jessebeach, catch: Add leading underscore and other discouragement to drupal_add_css() and drupal_add_js().
parent 9e239760
......@@ -245,14 +245,14 @@ function ajax_render($commands = array()) {
$items[$type] = array();
}
else {
$function = 'drupal_add_' . $type;
$function = '_drupal_add_' . $type;
$items[$type] = $function();
drupal_alter($type, $items[$type]);
// @todo Inline CSS and JS items are indexed numerically. These can't be
// reliably diffed with array_diff_key(), since the number can change
// due to factors unrelated to the inline content, so for now, we strip
// the inline items from Ajax responses, and can add support for them
// when drupal_add_css() and drupal_add_js() are changed to use a hash
// when _drupal_add_css() and _drupal_add_js() are changed to use a hash
// of the inline content as the array key.
foreach ($items[$type] as $key => $item) {
if (is_numeric($key)) {
......@@ -290,7 +290,7 @@ function ajax_render($commands = array()) {
}
// Now add a command to merge changes and additions to drupalSettings.
$scripts = drupal_add_js();
$scripts = _drupal_add_js();
if (!empty($scripts['settings'])) {
$settings = drupal_merge_js_settings($scripts['settings']['data']);
array_unshift($commands, ajax_command_settings($settings, TRUE));
......
......@@ -1402,7 +1402,7 @@ function drupal_add_html_head_link($attributes, $header = FALSE) {
/**
* Adds a cascading stylesheet to the stylesheet queue.
*
* Calling drupal_static_reset('drupal_add_css') will clear all cascading
* Calling drupal_static_reset('_drupal_add_css') will clear all cascading
* stylesheets added so far.
*
* If CSS aggregation/compression is enabled, all cascading style sheets added
......@@ -1421,7 +1421,7 @@ function drupal_add_html_head_link($attributes, $header = FALSE) {
* all typical visitors and most pages of a site. It is critical that all
* preprocessed files are added unconditionally on every page, even if the
* files do not happen to be needed on a page. This is normally done by calling
* drupal_add_css() in a hook_page_build() implementation.
* _drupal_add_css() in a hook_page_build() implementation.
*
* Non-preprocessed files should only be added to the page when they are
* actually needed.
......@@ -1494,9 +1494,9 @@ function drupal_add_html_head_link($attributes, $header = FALSE) {
* - Then by the 'every_page' flag, with TRUE coming before FALSE.
* - Then by weight.
* - Then by the order in which the CSS was added. For example, all else
* being the same, a stylesheet added by a call to drupal_add_css() that
* being the same, a stylesheet added by a call to _drupal_add_css() that
* happened later in the page request gets added to the page after one for
* which drupal_add_css() happened earlier in the page request.
* which _drupal_add_css() happened earlier in the page request.
* Available constants are:
* - CSS_BASE: Styles for HTML elements ("base" styles).
* - CSS_LAYOUT: Styles that layout a page.
......@@ -1523,7 +1523,7 @@ function drupal_add_html_head_link($attributes, $header = FALSE) {
*
* @see drupal_get_css()
*/
function drupal_add_css($data = NULL, $options = NULL) {
function _drupal_add_css($data = NULL, $options = NULL) {
$css = &drupal_static(__FUNCTION__, array());
// Construct the options, taking the defaults into consideration.
......@@ -1613,13 +1613,13 @@ function drupal_add_css($data = NULL, $options = NULL) {
* @return
* A string of XHTML CSS tags.
*
* @see drupal_add_css()
* @see _drupal_add_css()
*/
function drupal_get_css($css = NULL, $skip_alter = FALSE) {
global $theme_info;
if (!isset($css)) {
$css = drupal_add_css();
$css = _drupal_add_css();
}
// Allow modules and themes to alter the CSS items.
......@@ -1672,12 +1672,12 @@ function drupal_get_css($css = NULL, $skip_alter = FALSE) {
*
* @param $a
* First item for comparison. The compared items should be associative arrays
* of member items from drupal_add_css() or drupal_add_js().
* of member items from _drupal_add_css() or _drupal_add_js().
* @param $b
* Second item for comparison.
*
* @see drupal_add_css()
* @see drupal_add_js()
* @see _drupal_add_css()
* @see _drupal_add_js()
*/
function drupal_sort_css_js($a, $b) {
// First order by group, so that all items in the CSS_AGGREGATE_DEFAULT group
......@@ -1759,7 +1759,7 @@ function drupal_sort_css_js($a, $b) {
*
* @param $element
* A render array containing:
* - '#items': The CSS items as returned by drupal_add_css() and altered by
* - '#items': The CSS items as returned by _drupal_add_css() and altered by
* drupal_get_css().
*
* @return
......@@ -1981,17 +1981,17 @@ function drupal_html_id($id) {
*
* Examples:
* @code
* drupal_add_js('core/misc/collapse.js');
* drupal_add_js('core/misc/collapse.js', 'file');
* drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
* drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
* _drupal_add_js('core/misc/collapse.js');
* _drupal_add_js('core/misc/collapse.js', 'file');
* _drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
* _drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
* array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
* );
* drupal_add_js('http://example.com/example.js', 'external');
* drupal_add_js(array('myModule' => array('key' => 'value')), 'setting');
* _drupal_add_js('http://example.com/example.js', 'external');
* _drupal_add_js(array('myModule' => array('key' => 'value')), 'setting');
* @endcode
*
* Calling drupal_static_reset('drupal_add_js') will clear all JavaScript added
* Calling drupal_static_reset('_drupal_add_js') will clear all JavaScript added
* so far.
*
* If JavaScript aggregation is enabled, all JavaScript files added with
......@@ -2008,7 +2008,7 @@ function drupal_html_id($id) {
* all typical visitors and most pages of a site. It is critical that all
* preprocessed files are added unconditionally on every page, even if the
* files are not needed on a page. This is normally done by calling
* drupal_add_js() in a hook_page_build() implementation.
* _drupal_add_js() in a hook_page_build() implementation.
*
* Non-preprocessed files should only be added to the page when they are
* actually needed.
......@@ -2085,9 +2085,9 @@ function drupal_html_id($id) {
* - Then by the 'every_page' flag, with TRUE coming before FALSE.
* - Then by weight.
* - Then by the order in which the JavaScript was added. For example, all
* else being the same, JavaScript added by a call to drupal_add_js() that
* else being the same, JavaScript added by a call to _drupal_add_js() that
* happened later in the page request gets added to the page after one for
* which drupal_add_js() happened earlier in the page request.
* which _drupal_add_js() happened earlier in the page request.
* - cache: If set to FALSE, the JavaScript file is loaded anew on every page
* call; in other words, it is not cached. Used only when 'type' references
* a JavaScript file. Defaults to TRUE.
......@@ -2104,13 +2104,13 @@ function drupal_html_id($id) {
* @return
* The current array of JavaScript files, settings, and in-line code,
* including Drupal defaults, anything previously added with calls to
* drupal_add_js(), and this function call's additions.
* _drupal_add_js(), and this function call's additions.
*
* @deprecated as of Drupal 8.0. Use the #attached key in render arrays instead.
*
* @see drupal_get_js()
*/
function drupal_add_js($data = NULL, $options = NULL) {
function _drupal_add_js($data = NULL, $options = NULL) {
$javascript = &drupal_static(__FUNCTION__, array());
// Construct the options, taking the defaults into consideration.
......@@ -2128,7 +2128,7 @@ function drupal_add_js($data = NULL, $options = NULL) {
$options['preprocess'] = $options['cache'] && empty($options['attributes']) ? $options['preprocess'] : FALSE;
// Tweak the weight so that files of the same weight are included in the
// order of the calls to drupal_add_js().
// order of the calls to _drupal_add_js().
$options['weight'] += count($javascript) / 1000;
if (isset($data)) {
switch ($options['type']) {
......@@ -2189,7 +2189,7 @@ function drupal_add_js($data = NULL, $options = NULL) {
* (optional) The default data parameter for the JavaScript item array.
*
* @see drupal_get_js()
* @see drupal_add_js()
* @see _drupal_add_js()
*/
function drupal_js_defaults($data = NULL) {
return array(
......@@ -2217,7 +2217,7 @@ function drupal_js_defaults($data = NULL) {
*
* Note that hook_js_alter(&$javascript) is called during this function call
* to allow alterations of the JavaScript during its presentation. Calls to
* drupal_add_js() from hook_js_alter() will not be added to the output
* _drupal_add_js() from hook_js_alter() will not be added to the output
* presentation. The correct way to add JavaScript during hook_js_alter()
* is to add another element to the $javascript array, deriving from
* drupal_js_defaults(). See locale_js_alter() for an example of this.
......@@ -2239,13 +2239,13 @@ function drupal_js_defaults($data = NULL) {
* @return
* All JavaScript code segments and includes for the scope as HTML tags.
*
* @see drupal_add_js()
* @see _drupal_add_js()
* @see locale_js_alter()
* @see drupal_js_defaults()
*/
function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALSE, $is_ajax = FALSE) {
if (!isset($javascript)) {
$javascript = drupal_add_js();
$javascript = _drupal_add_js();
}
if (empty($javascript)) {
return '';
......@@ -2294,17 +2294,17 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
// Skip if no files were added to the page otherwise jQuery.extend() will
// overwrite the drupalSettings.ajaxPageState.css object with an empty
// array.
$css = drupal_add_css();
$css = _drupal_add_css();
if (!empty($css)) {
// Cast the array to an object to be on the safe side even if not empty.
$setting['ajaxPageState']['css'] = (object) array_fill_keys(array_keys($css), 1);
}
drupal_add_js($setting, 'setting');
_drupal_add_js($setting, 'setting');
// If we're outputting the header scope, then this might be the final time
// that drupal_get_js() is running, so add the settings to this output as well
// as to the drupal_add_js() cache. If $items['settings'] doesn't exist, it's
// as to the _drupal_add_js() cache. If $items['settings'] doesn't exist, it's
// because drupal_get_js() was intentionally passed a $javascript argument
// stripped of settings, potentially in order to override how settings get
// output, so in this case, do not add the setting to this output.
......@@ -2356,7 +2356,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
*
* By following jQuery.extend() merge logic rather than common PHP array merge
* logic, the following are ensured:
* - drupal_add_js() is idempotent: calling it twice with the same parameters
* - _drupal_add_js() is idempotent: calling it twice with the same parameters
* does not change the output sent to the browser.
* - If pieces of the page are rendered in separate PHP requests and the
* returned settings are merged by JavaScript, the resulting settings are the
......@@ -2365,7 +2365,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
* @param $settings_items
* An array of settings arrays, as returned by:
* @code
* $js = drupal_add_js();
* $js = _drupal_add_js();
* $settings_items = $js['settings']['data'];
* @endcode
*
......@@ -2373,7 +2373,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
* A merged $settings array, suitable for JSON encoding and returning to the
* browser.
*
* @see drupal_add_js()
* @see _drupal_add_js()
* @see drupal_pre_render_scripts()
*/
function drupal_merge_js_settings($settings_items) {
......@@ -2406,7 +2406,7 @@ function drupal_merge_attached(array $a, array $b) {
*
* @param $element
* A render array containing:
* - #items: The JavaScript items as returned by drupal_add_js() and
* - #items: The JavaScript items as returned by _drupal_add_js() and
* altered by drupal_get_js().
* - #group_callback: A function to call to group #items. Following
* this function, #aggregate_callback is called to aggregate items within
......@@ -2437,6 +2437,7 @@ function drupal_pre_render_scripts($elements) {
* to elements using the #attached property. The #attached property is an
* associative array, where the keys are the the attachment types and the values
* are the attached data. For example:
*
* @code
* $build['#attached'] = array(
* 'library' => array(array('taxonomy', 'taxonomy')),
......@@ -2474,8 +2475,8 @@ function drupal_pre_render_scripts($elements) {
* dependencies were met.
*
* @see drupal_add_library()
* @see drupal_add_js()
* @see drupal_add_css()
* @see _drupal_add_js()
* @see _drupal_add_css()
* @see drupal_render()
*/
function drupal_process_attached($elements, $dependency_check = FALSE) {
......@@ -2500,7 +2501,7 @@ function drupal_process_attached($elements, $dependency_check = FALSE) {
unset($elements['#attached']['library']);
// Add both the JavaScript and the CSS.
// The parameters for drupal_add_js() and drupal_add_css() require special
// The parameters for _drupal_add_js() and _drupal_add_css() require special
// handling.
foreach (array('js', 'css') as $type) {
foreach ($elements['#attached'][$type] as $data => $options) {
......@@ -2516,7 +2517,7 @@ function drupal_process_attached($elements, $dependency_check = FALSE) {
$data = $options['data'];
unset($options['data']);
}
call_user_func('drupal_add_' . $type, $data, $options);
call_user_func('_drupal_add_' . $type, $data, $options);
}
unset($elements['#attached'][$type]);
}
......
......@@ -2495,7 +2495,7 @@ function template_preprocess_maintenance_page(&$variables) {
// While this code is used in the installer, the language module may not be
// enabled yet (even maybe no database set up yet), but an RTL language
// selected should result in RTL stylesheets loaded properly already.
$css = drupal_add_css();
$css = _drupal_add_css();
include_once DRUPAL_ROOT . '/core/modules/language/language.module';
// Wrapping drupal_get_css() and drupal_get_js() in an object so they can
// be called when printed.
......
......@@ -104,14 +104,14 @@ protected function ajaxRender(Request $request) {
$items[$type] = array();
}
else {
$function = 'drupal_add_' . $type;
$function = '_drupal_add_' . $type;
$items[$type] = $function();
drupal_alter($type, $items[$type]);
// @todo Inline CSS and JS items are indexed numerically. These can't be
// reliably diffed with array_diff_key(), since the number can change
// due to factors unrelated to the inline content, so for now, we
// strip the inline items from Ajax responses, and can add support for
// them when drupal_add_css() and drupal_add_js() are changed to use
// them when _drupal_add_css() and _drupal_add_js() are changed to use
// a hash of the inline content as the array key.
foreach ($items[$type] as $key => $item) {
if (is_numeric($key)) {
......@@ -150,7 +150,7 @@ protected function ajaxRender(Request $request) {
}
// Prepend a command to merge changes and additions to drupalSettings.
$scripts = drupal_add_js();
$scripts = _drupal_add_js();
if (!empty($scripts['settings'])) {
$settings = drupal_merge_js_settings($scripts['settings']['data']);
// During Ajax requests basic path-specific settings are excluded from
......@@ -158,7 +158,7 @@ protected function ajaxRender(Request $request) {
// from already has the right values for the keys below. An Ajax request
// would update them with values for the Ajax request and incorrectly
// override the page's values.
// @see drupal_add_js
// @see _drupal_add_js()
foreach (array('basePath', 'currentPath', 'scriptPath', 'pathPrefix') as $item) {
unset($settings[$item]);
}
......
......@@ -58,7 +58,7 @@ public function group(array $css_assets) {
// Group file items if their 'preprocess' flag is TRUE.
// Help ensure maximum reuse of aggregate files by only grouping
// together items that share the same 'group' value and 'every_page'
// flag. See drupal_add_css() for details about that.
// flag. See _drupal_add_css() for details about that.
$group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['every_page'], $item['media'], $item['browsers']) : FALSE;
break;
......
......@@ -45,7 +45,7 @@ public function group(array $js_assets) {
// Group file items if their 'preprocess' flag is TRUE.
// Help ensure maximum reuse of aggregate files by only grouping
// together items that share the same 'group' value and 'every_page'
// flag. See drupal_add_js() for details about that.
// flag. See _drupal_add_js() for details about that.
$group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['every_page'], $item['browsers']) : FALSE;
break;
......
......@@ -39,7 +39,7 @@ public function render(array $js_assets) {
// A dummy query-string is added to filenames, to gain control over
// browser-caching. The string changes on every update or full cache
// flush, forcing browsers to load a new copy of the files, as the
// URL changed. Files that should not be cached (see drupal_add_js())
// URL changed. Files that should not be cached (see _drupal_add_js())
// get REQUEST_TIME as query-string instead, to enforce reload on every
// page request.
$default_query_string = $this->state->get('system.css_js_query_string') ?: '0';
......
......@@ -275,8 +275,8 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view
// When working with a hidden form, we don't want any CSS or JS to be loaded.
if ($request->request->get('nocssjs') === 'true') {
drupal_static_reset('drupal_add_css');
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_css');
drupal_static_reset('_drupal_add_js');
}
return $response;
......
......@@ -91,7 +91,7 @@ function hook_editor_default_settings_alter(&$default_settings, $editor) {
* Modifies JavaScript settings that are added for text editors.
*
* @param array $settings
* All the settings that will be added to the page via drupal_add_js() for
* All the settings that will be added to the page via _drupal_add_js() for
* the text formats to which a user has access.
* @param array $formats
* The list of format objects for which settings are being added.
......
......@@ -75,7 +75,7 @@ public function upload(Request $request) {
$status_messages = array('#theme' => 'status_messages');
$form['#prefix'] .= drupal_render($status_messages);
$output = drupal_render($form);
$js = drupal_add_js();
$js = _drupal_add_js();
$settings = drupal_merge_js_settings($js['settings']['data']);
$response = new AjaxResponse();
......
......@@ -31,10 +31,10 @@ public static function getInfo() {
*/
public function testAJAXRender() {
// Verify that settings command is generated when JavaScript settings are
// set via drupal_add_js().
// set via _drupal_add_js().
$commands = $this->drupalGetAJAX('ajax-test/render');
$expected = new SettingsCommand(array('ajax' => 'test'), TRUE);
$this->assertCommand($commands, $expected->render(), 'ajax_render() loads settings added with drupal_add_js().');
$this->assertCommand($commands, $expected->render(), 'ajax_render() loads settings added with _drupal_add_js().');
}
/**
......@@ -46,7 +46,7 @@ public function testOrder() {
// Expected commands, in a very specific order.
$expected_commands[0] = new SettingsCommand(array('ajax' => 'test'), TRUE);
drupal_static_reset('drupal_add_css');
drupal_static_reset('_drupal_add_css');
$attached = array(
'#attached' => array(
'css' => array(
......@@ -56,8 +56,8 @@ public function testOrder() {
),
);
drupal_render($attached);
$expected_commands[1] = new AddCssCommand(drupal_get_css(drupal_add_css(), TRUE));
drupal_static_reset('drupal_add_js');
$expected_commands[1] = new AddCssCommand(drupal_get_css(_drupal_add_css(), TRUE));
drupal_static_reset('_drupal_add_js');
$attached = array(
'#attached' => array(
'js' => array(
......@@ -66,8 +66,8 @@ public function testOrder() {
),
);
drupal_render($attached);
$expected_commands[2] = new PrependCommand('head', drupal_get_js('header', drupal_add_js(), TRUE));
drupal_static_reset('drupal_add_js');
$expected_commands[2] = new PrependCommand('head', drupal_get_js('header', _drupal_add_js(), TRUE));
drupal_static_reset('_drupal_add_js');
$attached = array(
'#attached' => array(
'js' => array(
......@@ -76,7 +76,7 @@ public function testOrder() {
),
);
drupal_render($attached);
$expected_commands[3] = new AppendCommand('body', drupal_get_js('footer', drupal_add_js(), TRUE));
$expected_commands[3] = new AppendCommand('body', drupal_get_js('footer', _drupal_add_js(), TRUE));
$expected_commands[4] = new HtmlCommand('body', 'Hello, world!');
// Load any page with at least one CSS file, at least one JavaScript file
......@@ -123,7 +123,7 @@ public function testLazyLoad() {
'css' => drupal_get_path('module', 'system') . '/css/system.admin.css',
'js' => drupal_get_path('module', 'system') . '/system.js',
);
// CSS files are stored by basename, see drupal_add_css().
// CSS files are stored by basename, see _drupal_add_css().
$expected_css_basename = drupal_basename($expected['css']);
// @todo D8: Add a drupal_css_defaults() helper function.
......
......@@ -32,15 +32,15 @@ public static function getInfo() {
function setUp() {
parent::setUp();
// Reset drupal_add_css() before each test.
drupal_static_reset('drupal_add_css');
// Reset _drupal_add_css() before each test.
drupal_static_reset('_drupal_add_css');
}
/**
* Checks that default stylesheets are empty.
*/
function testDefault() {
$this->assertEqual(array(), drupal_add_css(), 'Default CSS is empty.');
$this->assertEqual(array(), _drupal_add_css(), 'Default CSS is empty.');
}
/**
......@@ -48,7 +48,7 @@ function testDefault() {
*/
function testAddFile() {
$path = drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css';
$css = drupal_add_css($path);
$css = _drupal_add_css($path);
$this->assertEqual($css['simpletest.module.css']['data'], $path);
}
......@@ -57,7 +57,7 @@ function testAddFile() {
*/
function testAddExternal() {
$path = 'http://example.com/style.css';
$css = drupal_add_css($path, 'external');
$css = _drupal_add_css($path, 'external');
$this->assertEqual($css[$path]['type'], 'external', 'Adding an external CSS file caches it properly.');
}
......@@ -65,8 +65,8 @@ function testAddExternal() {
* Makes sure that resetting the CSS empties the cache.
*/
function testReset() {
drupal_static_reset('drupal_add_css');
$this->assertEqual(array(), drupal_add_css(), 'Resetting the CSS empties the cache.');
drupal_static_reset('_drupal_add_css');
$this->assertEqual(array(), _drupal_add_css(), 'Resetting the CSS empties the cache.');
}
/**
......@@ -74,7 +74,7 @@ function testReset() {
*/
function testRenderFile() {
$css = drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css';
drupal_add_css($css);
_drupal_add_css($css);
$styles = drupal_get_css();
$this->assertTrue(strpos($styles, $css) > 0, 'Rendered CSS includes the added stylesheet.');
// Verify that newlines are properly added inside style tags.
......@@ -88,7 +88,7 @@ function testRenderFile() {
*/
function testRenderExternal() {
$css = 'http://example.com/style.css';
drupal_add_css($css, 'external');
_drupal_add_css($css, 'external');
$styles = drupal_get_css();
// Stylesheet URL may be the href of a LINK tag or in an @import statement
// of a STYLE tag.
......@@ -105,7 +105,7 @@ function testRenderInlinePreprocess() {
$css = 'body { padding: 0px; }';
$css_preprocessed = '<style media="all">' . "\n/* <![CDATA[ */\n" . "body{padding:0px;}\n" . "\n/* ]]> */\n" . '</style>';
drupal_add_css($css, array('type' => 'inline'));
_drupal_add_css($css, array('type' => 'inline'));
$styles = drupal_get_css();
$this->assertEqual(trim($styles), $css_preprocessed, 'Rendering preprocessed inline CSS adds it to the page.');
}
......@@ -115,7 +115,7 @@ function testRenderInlinePreprocess() {
*/
function testRenderInlineNoPreprocess() {
$css = 'body { padding: 0px; }';
drupal_add_css($css, array('type' => 'inline', 'preprocess' => FALSE));
_drupal_add_css($css, array('type' => 'inline', 'preprocess' => FALSE));
$styles = drupal_get_css();
$this->assertTrue(strpos($styles, $css) > 0, 'Rendering non-preprocessed inline CSS adds it to the page.');
}
......@@ -125,12 +125,12 @@ function testRenderInlineNoPreprocess() {
*/
function testRenderOrder() {
// Load a module CSS file.
drupal_add_css(drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css');
_drupal_add_css(drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css');
// Load a few system CSS files in a custom, early-loading aggregate group.
$test_aggregate_group = -100;
$system_path = drupal_get_path('module', 'system');
drupal_add_css($system_path . '/css/system.module.css', array('group' => $test_aggregate_group, 'weight' => -10));
drupal_add_css($system_path . '/css/system.theme.css', array('group' => $test_aggregate_group));
_drupal_add_css($system_path . '/css/system.module.css', array('group' => $test_aggregate_group, 'weight' => -10));
_drupal_add_css($system_path . '/css/system.theme.css', array('group' => $test_aggregate_group));
$expected = array(
$system_path . '/css/system.module.css',
......@@ -157,16 +157,16 @@ function testRenderOrder() {
function testRenderOverride() {
$system = drupal_get_path('module', 'system');
drupal_add_css($system . '/css/system.module.css');
drupal_add_css($system . '/tests/css/system.module.css');
_drupal_add_css($system . '/css/system.module.css');
_drupal_add_css($system . '/tests/css/system.module.css');
// The dummy stylesheet should be the only one included.
$styles = drupal_get_css();
$this->assert(strpos($styles, $system . '/tests/css/system.module.css') !== FALSE, 'The overriding CSS file is output.');
$this->assert(strpos($styles, $system . '/css/system.module.css') === FALSE, 'The overridden CSS file is not output.');
drupal_add_css($system . '/tests/css/system.module.css');
drupal_add_css($system . '/css/system.module.css');
_drupal_add_css($system . '/tests/css/system.module.css');
_drupal_add_css($system . '/css/system.module.css');
// The standard stylesheet should be the only one included.
$styles = drupal_get_css();
......@@ -180,8 +180,8 @@ function testRenderOverride() {
function testAddCssFileWithQueryString() {
$css_without_query_string = drupal_get_path('module', 'node') . '/css/node.admin.css';
$css_with_query_string = '/' . drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2';
drupal_add_css($css_without_query_string);
drupal_add_css($css_with_query_string);
_drupal_add_css($css_without_query_string);
_drupal_add_css($css_with_query_string);
$styles = drupal_get_css();
$query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
......
......@@ -369,7 +369,7 @@ function testDrupalRenderChildrenAttached() {
// Load the element from cache and verify the presence of the #attached
// JavaScript.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element = array('#cache' => array('keys' => array('simpletest', 'drupal_render', 'children_attached')));
$this->assertTrue(strlen(drupal_render($element)) > 0, 'The element was retrieved from cache.');
$scripts = drupal_get_js();
......@@ -461,7 +461,7 @@ function testDrupalRenderPostRenderCache() {
);
// #cache disabled.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#markup'] = '<p>#cache disabled</p>';