Commit 99d3490f authored by webchick's avatar webchick

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));
......
This diff is collapsed.
......@@ -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>';
$output = drupal_render($element);
......@@ -477,7 +477,7 @@ function testDrupalRenderPostRenderCache() {
\Drupal::request()->setMethod('GET');
// GET request: #cache enabled, cache miss.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache'] = array('cid' => 'post_render_cache_test_GET');
$element['#markup'] = '<p>#cache enabled, GET</p>';
......@@ -501,7 +501,7 @@ function testDrupalRenderPostRenderCache() {
$this->assertIdentical($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
// GET request: #cache enabled, cache hit.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element['#cache'] = array('cid' => 'post_render_cache_test_GET');
$element['#markup'] = '<p>#cache enabled, GET</p>';
$output = drupal_render($element);
......@@ -518,7 +518,7 @@ function testDrupalRenderPostRenderCache() {
\Drupal::request()->setMethod('POST');
// POST request: #cache enabled, cache miss.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache'] = array('cid' => 'post_render_cache_test_POST');
$element['#markup'] = '<p>#cache enabled, POST</p>';
......@@ -551,7 +551,7 @@ function testDrupalRenderChildrenPostRenderCache() {
// Test case 1.
// Create an element with a child and subchild. Each element has the same
// #post_render_cache callback, but with different contexts.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$context_1 = array('foo' => $this->randomString());
$context_2 = array('bar' => $this->randomString());
$context_3 = array('baz' => $this->randomString());
......@@ -621,7 +621,7 @@ function testDrupalRenderChildrenPostRenderCache() {
$this->assertIdentical($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
// GET request: #cache enabled, cache hit.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element = $test_element;
$output = drupal_render($element);
$this->assertIdentical($output, '<p>overridden</p>', 'Output is overridden.');
......@@ -639,7 +639,7 @@ function testDrupalRenderChildrenPostRenderCache() {
// #post_render_cache callbacks. I.e. the #post_render_cache callbacks may
// not yet have run, or otherwise the cached parent element would contain
// personalized data, thereby breaking the render cache.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_parent');
$element['child']['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_child');
......@@ -699,7 +699,7 @@ function testDrupalRenderChildrenPostRenderCache() {
$this->assertIdentical($cached_child_element, $expected_child_element, 'The correct data is cached for the child: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
// GET request: #cache enabled, cache hit, parent element.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_parent');
$output = drupal_render($element);
......@@ -711,7 +711,7 @@ function testDrupalRenderChildrenPostRenderCache() {
$this->assertIdentical($settings['common_test'], $expected_settings, '#attached is modified; JavaScript settings for each #post_render_cache callback are added to page.');
// GET request: #cache enabled, cache hit, child element.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['child']['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_child');
$element = $element['child'];
......@@ -744,7 +744,7 @@ function testDrupalRenderRenderCachePlaceholder() {
$expected_output = '<foo><bar>' . $context['bar'] . '</bar></foo>';
// #cache disabled.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element = $test_element;
$output = drupal_render($element);
$this->assertIdentical($output, $expected_output, 'Placeholder was replaced in output');
......@@ -756,7 +756,7 @@ function testDrupalRenderRenderCachePlaceholder() {
\Drupal::request()->setMethod('GET');
// GET request: #cache enabled, cache miss.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache'] = array('cid' => 'render_cache_placeholder_test_GET');
$output = drupal_render($element);
......@@ -785,7 +785,7 @@ function testDrupalRenderRenderCachePlaceholder() {
$this->assertIdentical($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
// GET request: #cache enabled, cache hit.
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache'] = array('cid' => 'render_cache_placeholder_test_GET');
$output = drupal_render($element);
......
......@@ -28,10 +28,10 @@ function testThemeTableStickyHeaders() {
$header = array('one', 'two', 'three');
$rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
$this->content = theme('table', array('header' => $header, 'rows' => $rows, 'sticky' => TRUE));
$js = drupal_add_js();
$js = _drupal_add_js();
$this->assertTrue(isset($js['core/misc/tableheader.js']), 'tableheader.js was included when $sticky = TRUE.');
$this->assertRaw('sticky-enabled', 'Table has a class of sticky-enabled when $sticky = TRUE.');
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
}
/**
......@@ -44,10 +44,10 @@ function testThemeTableNoStickyHeaders() {
$caption = NULL;
$colgroups = array();
$this->content = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes, 'caption' => $caption, 'colgroups' => $colgroups, 'sticky' => FALSE));
$js = drupal_add_js();
$js = _drupal_add_js();
$this->assertFalse(isset($js['core/misc/tableheader.js']), 'tableheader.js was not included because $sticky = FALSE.');
$this->assertNoRaw('sticky-enabled', 'Table does not have a class of sticky-enabled because $sticky = FALSE.');
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_js');
}
/**
......
......@@ -270,7 +270,7 @@ function hook_element_info_alter(&$type) {
* @param $javascript
* An array of all JavaScript being presented on the page.
*
* @see drupal_add_js()
* @see _drupal_add_js()
* @see drupal_get_js()
* @see drupal_js_defaults()
*/
......@@ -293,11 +293,11 @@ function hook_js_alter(&$javascript) {
* version_compare() to compare different versions.
* - 'js': An array of JavaScript elements; each element's key is used as $data
* argument, each element's value is used as $options array for
* drupal_add_js(). To add library-specific (not module-specific) JavaScript
* _drupal_add_js(). To add library-specific (not module-specific) JavaScript
* settings, the key may be skipped, the value must specify
* 'type' => 'setting', and the actual settings must be contained in a 'data'
* element of the value.
* - 'css': Like 'js', an array of CSS elements passed to drupal_add_css().
* - 'css': Like 'js', an array of CSS elements passed to _drupal_add_css().
* - 'dependencies': An array of libraries that are required for a library. Each
* element is an array listing the module and name of another library. Note
* that all dependencies for each dependent library will also be added when
......@@ -390,7 +390,7 @@ function hook_library_info_alter(&$libraries, $module) {
* @param $css
* An array of all CSS items (files and inline CSS) being requested on the page.
*
* @see drupal_add_css()
* @see _drupal_add_css()
* @see drupal_get_css()
*/
function hook_css_alter(&$css) {
......@@ -2572,7 +2572,7 @@ function hook_install_tasks(&$install_state) {
*
* Elements available to be altered are only those added using
* drupal_add_html_head_link() or drupal_add_html_head(). CSS and JS files
* are handled using drupal_add_css() and drupal_add_js(), so the head links
* are handled using _drupal_add_css() and _drupal_add_js(), so the head links
* for those files will not appear in the $head_elements array.
*
* @param $head_elements
......
......@@ -24,7 +24,7 @@ function ajax_test_system_theme_info() {
* Menu callback: Returns an element suitable for use by ajax_render().
*
* Additionally ensures that ajax_render() incorporates JavaScript settings
* generated during the page request by invoking drupal_add_js() with a dummy
* generated during the page request by invoking _drupal_add_js() with a dummy
* setting.
*
* @deprecated \Drupal\ajax_test\Controller\AjaxTestController::render()
......
......@@ -142,17 +142,17 @@ function testHeaderStorage() {
$output = $view->preview();
drupal_render($output);
unset($view->pre_render_called);
drupal_static_reset('drupal_add_css');
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_css');
drupal_static_reset('_drupal_add_js');
$view->destroy();
$view->setDisplay();
$output = $view->preview();
drupal_render($output);
$css = drupal_add_css();
$css = _drupal_add_css();
$css_path = drupal_get_path('module', 'views_test_data') . '/views_cache.test.css';
$js_path = drupal_get_path('module', 'views_test_data') . '/views_cache.test.js';
$js = drupal_add_js();
$js = _drupal_add_js();
$this->assertTrue(isset($css[basename($css_path)]), 'Make sure the css is added for cached views.');
$this->assertTrue(isset($js[$js_path]), 'Make sure the js is added for cached views.');
......@@ -176,15 +176,15 @@ function testHeaderStorage() {
$output = $view->preview();
drupal_render($output);
drupal_static_reset('drupal_add_css');
drupal_static_reset('drupal_add_js');
drupal_static_reset('_drupal_add_css');
drupal_static_reset('_drupal_add_js');
$view->destroy();
$output = $view->preview();
drupal_render($output);
$css = drupal_add_css();
$js = drupal_add_js();
$css = _drupal_add_css();
$js = _drupal_add_js();
$this->assertFalse(isset($css['system.maintenance.css']), 'Make sure that unrelated css is not added.');
$this->assertFalse(isset($js[drupal_get_path('module', 'user') . '/user.permissions.js']), 'Make sure that unrelated js is not added.');
......
......@@ -122,11 +122,11 @@ public function getForm(ViewStorageInterface $view, $display_id, $js) {
// With the below logic, we may end up rendering a form twice (or two forms
// each sharing the same element ids), potentially resulting in
// drupal_add_js() being called twice to add the same setting. drupal_get_js()
// _drupal_add_js() being called twice to add the same setting. drupal_get_js()
// is ok with that, but until ajax_render() is (http://drupal.org/node/208611),
// reset the drupal_add_js() static before rendering the second time.
$drupal_add_js_original = drupal_add_js();
$drupal_add_js = &drupal_static('drupal_add_js');
// reset the _drupal_add_js() static before rendering the second time.
$drupal_add_js_original = _drupal_add_js();
$drupal_add_js = &drupal_static('_drupal_add_js');
$response = views_ajax_form_wrapper($form_state['form_id'], $form_state);
// If the form has not been submitted, or was not set for rerendering, stop.
......
......@@ -73,8 +73,8 @@ protected function prepareEntity() {
*
* This returns an array of arrays. Each array represents a single
* file. The array format is:
* - file: The fully qualified name of the file to send to drupal_add_css
* - options: An array of options to pass to drupal_add_css.
* - file: The fully qualified name of the file to send to _drupal_add_css
* - options: An array of options to pass to _drupal_add_css.
*/
public static function getAdminCSS() {
$module_path = drupal_get_path('module', 'views_ui');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment