updated core and modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-09-09 16:27:51 +02:00
parent 027aa99b32
commit 41863f872c
7810 changed files with 318922 additions and 83631 deletions
+17 -17
View File
@@ -18,35 +18,35 @@ class Toolbar extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
return array(
'#pre_render' => array(
array($class, 'preRenderToolbar'),
),
return [
'#pre_render' => [
[$class, 'preRenderToolbar'],
],
'#theme' => 'toolbar',
'#attached' => array(
'library' => array(
'#attached' => [
'library' => [
'toolbar/toolbar',
),
),
],
],
// Metadata for the toolbar wrapping element.
'#attributes' => array(
'#attributes' => [
// The id cannot be simply "toolbar" or it will clash with the
// simpletest tests listing which produces a checkbox with attribute
// id="toolbar".
'id' => 'toolbar-administration',
'role' => 'group',
'aria-label' => $this->t('Site administration toolbar'),
),
],
// Metadata for the administration bar.
'#bar' => array(
'#bar' => [
'#heading' => $this->t('Toolbar items'),
'#attributes' => array(
'#attributes' => [
'id' => 'toolbar-bar',
'role' => 'navigation',
'aria-label' => $this->t('Toolbar items'),
),
),
);
],
],
];
}
/**
@@ -68,7 +68,7 @@ class Toolbar extends RenderElement {
// toolbar presentation.
$breakpoints = static::breakpointManager()->getBreakpointsByGroup('toolbar');
if (!empty($breakpoints)) {
$media_queries = array();
$media_queries = [];
foreach ($breakpoints as $id => $breakpoint) {
$media_queries[$id] = $breakpoint->getMediaQuery();
}
@@ -82,7 +82,7 @@ class Toolbar extends RenderElement {
// Allow for altering of hook_toolbar().
$module_handler->alter('toolbar', $items);
// Sort the children.
uasort($items, array('\Drupal\Component\Utility\SortArray', 'sortByWeightProperty'));
uasort($items, ['\Drupal\Component\Utility\SortArray', 'sortByWeightProperty']);
// Merge in the original toolbar values.
$element = array_merge($element, $items);
@@ -19,16 +19,16 @@ class ToolbarItem extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
return array(
'#pre_render' => array(
array($class, 'preRenderToolbarItem'),
),
'tab' => array(
return [
'#pre_render' => [
[$class, 'preRenderToolbarItem'],
],
'tab' => [
'#type' => 'link',
'#title' => NULL,
'#url' => Url::fromRoute('<front>'),
),
);
],
];
}
/**
@@ -47,33 +47,33 @@ class ToolbarItem extends RenderElement {
$id = $element['#id'];
// Provide attributes for a toolbar item.
$attributes = array(
$attributes = [
'id' => $id,
);
];
// If tray content is present, markup the tray and its associated trigger.
if (!empty($element['tray'])) {
// Provide attributes necessary for trays.
$attributes += array(
$attributes += [
'data-toolbar-tray' => $id . '-tray',
'aria-owns' => $id . '-tray',
'role' => 'button',
'aria-pressed' => 'false',
);
];
// Merge in module-provided attributes.
$element['tab'] += array('#attributes' => array());
$element['tab'] += ['#attributes' => []];
$element['tab']['#attributes'] += $attributes;
$element['tab']['#attributes']['class'][] = 'trigger';
// Provide attributes for the tray theme wrapper.
$attributes = array(
$attributes = [
'id' => $id . '-tray',
'data-toolbar-tray' => $id . '-tray',
);
];
// Merge in module-provided attributes.
if (!isset($element['tray']['#wrapper_attributes'])) {
$element['tray']['#wrapper_attributes'] = array();
$element['tray']['#wrapper_attributes'] = [];
}
$element['tray']['#wrapper_attributes'] += $attributes;
$element['tray']['#wrapper_attributes']['class'][] = 'toolbar-tray';
@@ -15,7 +15,7 @@ class ToolbarMenuLinkTree extends MenuLinkTree {
public function build(array $tree, $level = 0) {
if ($level == 0) {
if (!$tree) {
return array();
return [];
}
$build = parent::build($tree, $level);
@@ -53,12 +53,12 @@ class ToolbarAdminMenuTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('node', 'block', 'menu_ui', 'user', 'taxonomy', 'toolbar', 'language', 'test_page_test', 'locale');
public static $modules = ['node', 'block', 'menu_ui', 'user', 'taxonomy', 'toolbar', 'language', 'test_page_test', 'locale'];
protected function setUp() {
parent::setUp();
$perms = array(
$perms = [
'access toolbar',
'access administration pages',
'administer site configuration',
@@ -75,7 +75,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
'administer taxonomy',
'administer languages',
'translate interface',
);
];
// Create an administrative user and log it in.
$this->adminUser = $this->drupalCreateUser($perms);
@@ -97,13 +97,13 @@ class ToolbarAdminMenuTest extends WebTestBase {
* Tests the toolbar_modules_installed() and toolbar_modules_uninstalled() hook
* implementations.
*/
function testModuleStatusChangeSubtreesHashCacheClear() {
public function testModuleStatusChangeSubtreesHashCacheClear() {
// Uninstall a module.
$edit = array();
$edit = [];
$edit['uninstall[taxonomy]'] = TRUE;
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
// Confirm the uninstall form.
$this->drupalPostForm(NULL, array(), t('Uninstall'));
$this->drupalPostForm(NULL, [], t('Uninstall'));
$this->rebuildContainer();
// Assert that the subtrees hash has been altered because the subtrees
@@ -111,8 +111,8 @@ class ToolbarAdminMenuTest extends WebTestBase {
$this->assertDifferentHash();
// Enable a module.
$edit = array();
$edit['modules[Core][taxonomy][enable]'] = TRUE;
$edit = [];
$edit['modules[taxonomy][enable]'] = TRUE;
$this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->rebuildContainer();
@@ -124,12 +124,12 @@ class ToolbarAdminMenuTest extends WebTestBase {
/**
* Tests toolbar cache tags implementation.
*/
function testMenuLinkUpdateSubtreesHashCacheClear() {
public function testMenuLinkUpdateSubtreesHashCacheClear() {
// The ID of a (any) admin menu link.
$admin_menu_link_id = 'system.admin_config_development';
// Disable the link.
$edit = array();
$edit = [];
$edit['enabled'] = FALSE;
$this->drupalPostForm("admin/structure/menu/link/" . $admin_menu_link_id . "/edit", $edit, t('Save'));
$this->assertResponse(200);
@@ -144,13 +144,13 @@ class ToolbarAdminMenuTest extends WebTestBase {
* Exercises the toolbar_user_role_update() and toolbar_user_update() hook
* implementations.
*/
function testUserRoleUpdateSubtreesHashCacheClear() {
public function testUserRoleUpdateSubtreesHashCacheClear() {
// Find the new role ID.
$all_rids = $this->adminUser->getRoles();
unset($all_rids[array_search(RoleInterface::AUTHENTICATED_ID, $all_rids)]);
$rid = reset($all_rids);
$edit = array();
$edit = [];
$edit[$rid . '[administer taxonomy]'] = FALSE;
$this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions'));
@@ -179,10 +179,10 @@ class ToolbarAdminMenuTest extends WebTestBase {
$this->hash = $this->getSubtreesHash();
$rid = $this->drupalCreateRole(array('administer content types',));
$rid = $this->drupalCreateRole(['administer content types']);
// Assign the role to the user.
$this->drupalPostForm('user/' . $this->adminUser->id() . '/edit', array("roles[$rid]" => $rid), t('Save'));
$this->drupalPostForm('user/' . $this->adminUser->id() . '/edit', ["roles[$rid]" => $rid], t('Save'));
$this->assertText(t('The changes have been saved.'));
// Assert that the subtrees hash has been altered because the subtrees
@@ -208,13 +208,13 @@ class ToolbarAdminMenuTest extends WebTestBase {
* Tests that changes to a user account by another user clears the changed
* account's toolbar cached, not the user's who took the action.
*/
function testNonCurrentUserAccountUpdates() {
public function testNonCurrentUserAccountUpdates() {
$admin_user_id = $this->adminUser->id();
$this->hash = $this->getSubtreesHash();
// adminUser2 will add a role to adminUser.
$this->drupalLogin($this->adminUser2);
$rid = $this->drupalCreateRole(array('administer content types',));
$rid = $this->drupalCreateRole(['administer content types']);
// Get the subtree hash for adminUser2 to check later that it has not
// changed. Request a new page to refresh the drupalSettings object.
@@ -223,7 +223,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
$admin_user_2_hash = $this->getSubtreesHash();
// Assign the role to the user.
$this->drupalPostForm('user/' . $admin_user_id . '/edit', array("roles[$rid]" => $rid), t('Save'));
$this->drupalPostForm('user/' . $admin_user_id . '/edit', ["roles[$rid]" => $rid], t('Save'));
$this->assertText(t('The changes have been saved.'));
// Log in adminUser and assert that the subtrees hash has changed.
@@ -243,10 +243,10 @@ class ToolbarAdminMenuTest extends WebTestBase {
/**
* Tests that toolbar cache is cleared when string translations are made.
*/
function testLocaleTranslationSubtreesHashCacheClear() {
public function testLocaleTranslationSubtreesHashCacheClear() {
$admin_user = $this->adminUser;
// User to translate and delete string.
$translate_user = $this->drupalCreateUser(array('translate interface', 'access administration pages'));
$translate_user = $this->drupalCreateUser(['translate interface', 'access administration pages']);
// Create a new language with the langcode 'xx'.
$langcode = 'xx';
@@ -257,14 +257,14 @@ class ToolbarAdminMenuTest extends WebTestBase {
// Add custom language.
$this->drupalLogin($admin_user);
$edit = array(
$edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
);
];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
t($name, array(), array('langcode' => $langcode));
t($name, [], ['langcode' => $langcode]);
// Reset locale cache.
$this->container->get('string_translation')->reset();
$this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
@@ -285,11 +285,11 @@ class ToolbarAdminMenuTest extends WebTestBase {
// should create a new menu hash if the toolbar subtrees cache is correctly
// invalidated.
$this->drupalLogin($translate_user);
$search = array(
$search = [
'string' => 'Search and metadata',
'langcode' => $langcode,
'translation' => 'untranslated',
);
];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available'));
$this->assertText($name, 'Search found the string as untranslated.');
@@ -298,9 +298,9 @@ class ToolbarAdminMenuTest extends WebTestBase {
// Translate the string to a random string.
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
$edit = array(
$edit = [
$lid => $translation,
);
];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
$this->assertText(t('The strings have been saved.'), 'The strings have been saved.');
$this->assertUrl(\Drupal::url('locale.translate_page', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
@@ -324,7 +324,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
/**
* Tests that the 'toolbar/subtrees/{hash}' is reachable and correct.
*/
function testSubtreesJsonRequest() {
public function testSubtreesJsonRequest() {
$admin_user = $this->adminUser;
$this->drupalLogin($admin_user);
// Request a new page to refresh the drupalSettings object.
@@ -339,7 +339,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
/**
* Test that subtrees hashes vary by the language of the page.
*/
function testLanguageSwitching() {
public function testLanguageSwitching() {
// Create a new language with the langcode 'xx'.
$langcode = 'xx';
$language = ConfigurableLanguage::createFromLangcode($langcode);
@@ -350,7 +350,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
$this->rebuildContainer();
// Get a page with the new language langcode in the URL.
$this->drupalGet('test-page', array('language' => $language));
$this->drupalGet('test-page', ['language' => $language]);
// Assert different hash.
$new_subtree_hash = $this->getSubtreesHash();
@@ -23,20 +23,20 @@ class ToolbarMenuTranslationTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('toolbar', 'toolbar_test', 'locale', 'locale_test');
public static $modules = ['toolbar', 'toolbar_test', 'locale', 'locale_test'];
protected function setUp() {
parent::setUp();
// Create an administrative user and log it in.
$this->adminUser = $this->drupalCreateUser(array('access toolbar', 'translate interface', 'administer languages', 'access administration pages'));
$this->adminUser = $this->drupalCreateUser(['access toolbar', 'translate interface', 'administer languages', 'access administration pages']);
$this->drupalLogin($this->adminUser);
}
/**
* Tests that toolbar classes don't change when adding a translation.
*/
function testToolbarClasses() {
public function testToolbarClasses() {
$langcode = 'es';
// Add Spanish.
@@ -50,11 +50,11 @@ class ToolbarMenuTranslationTest extends WebTestBase {
$this->drupalGet($langcode . '/admin/structure');
// Search for the menu item.
$search = array(
$search = [
'string' => $menu_item,
'langcode' => $langcode,
'translation' => 'untranslated',
);
];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
// Make sure will be able to translate the menu item.
$this->assertNoText('No strings available.', 'Search found the menu item as untranslated.');
@@ -67,17 +67,17 @@ class ToolbarMenuTranslationTest extends WebTestBase {
$menu_item_translated = $this->randomMachineName();
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
$edit = array(
$edit = [
$lid => $menu_item_translated,
);
];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Search for the translated menu item.
$search = array(
$search = [
'string' => $menu_item,
'langcode' => $langcode,
'translation' => 'translated',
);
];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
// Make sure the menu item string was translated.
$this->assertText($menu_item_translated, 'Search found the menu item as translated: ' . $menu_item_translated . '.');