diff --git a/core/lib/Drupal/Component/Discovery/DiscoverableInterface.php b/core/lib/Drupal/Component/Discovery/DiscoverableInterface.php index c04556f..02a5776 100644 --- a/core/lib/Drupal/Component/Discovery/DiscoverableInterface.php +++ b/core/lib/Drupal/Component/Discovery/DiscoverableInterface.php @@ -16,7 +16,7 @@ * Returns an array of discoverable items. * * @return array - * An array of discovered data keyed by provider. + * An array of discovered data. */ public function findAll(); diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 6c473f2..bf9aa88 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -1165,8 +1165,14 @@ protected function drupalStaticReset($name = NULL) { * @return \Drupal\Core\Session\AccountInterface */ protected function currentUser() { - if (!$this->currentUser && \Drupal::hasService('current_user')) { - $this->currentUser = \Drupal::currentUser(); + if (!$this->currentUser) { + if (\Drupal::hasService('current_user')) { + $this->currentUser = \Drupal::currentUser(); + } + else { + global $user; + $this->currentUser = $user; + } } return $this->currentUser; } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 54bfefa..199b3ae 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -787,8 +787,6 @@ function template_preprocess_comment(&$variables) { $permalink_uri_parent->setOption('attributes', $attributes); $variables['parent_title'] = \Drupal::linkGenerator()->generateFromUrl($comment_parent->getSubject(), $permalink_uri_parent); $variables['parent_permalink'] = \Drupal::linkGenerator()->generateFromUrl(t('Parent permalink'), $permalink_uri_parent); - $variables['parent'] = t('In reply to !parent_title by !parent_username', - array('!parent_username' => $variables['parent_author'], '!parent_title' => $variables['parent_title'])); } else { $variables['parent_comment'] = ''; @@ -797,7 +795,6 @@ function template_preprocess_comment(&$variables) { $variables['parent_changed'] = ''; $variables['parent_title'] = ''; $variables['parent_permalink'] = ''; - $variables['parent'] = ''; } // Helpful $content variable for templates. diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index a60bc83..f14b877 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -324,7 +324,8 @@ public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, * {@inheritdoc} */ public function hasParentComment() { - $parent = $this->get('pid')->entity; + // Do not load parent comment entity. + $parent = $this->get('pid')->target_id; return !empty($parent); } diff --git a/core/modules/comment/templates/comment.html.twig b/core/modules/comment/templates/comment.html.twig index 7ffb7c0..50497fd 100644 --- a/core/modules/comment/templates/comment.html.twig +++ b/core/modules/comment/templates/comment.html.twig @@ -43,21 +43,16 @@ * * These variables are provided to give context about the parent comment (if * any): - * - comment_parent: Full parent comment entity (if any). + * - parent_comment: Full parent comment entity (if any). * - parent_author: Equivalent to author for the parent comment. * - parent_created: Equivalent to created for the parent comment. * - parent_changed: Equivalent to changed for the parent comment. * - parent_title: Equivalent to title for the parent comment. * - parent_permalink: Equivalent to permalink for the parent comment. - * - parent: A text string of parent comment submission information created from - * 'parent_author' and 'parent_created' during template_preprocess_comment(). - * This information is presented to help screen readers follow lengthy - * discussion threads. You can hide this from sighted users using the class - * visually-hidden. * * These two variables are provided for context: * - comment: Full comment object. - * - entity: Entity the comments are attached to. + * - commented_entity: Entity the comments are attached to. * * @see template_preprocess_comment() * @@ -90,9 +85,12 @@ Indicate the semantic relationship between parent and child comments for accessibility. The list is difficult to navigate in a screen reader without this information. + This information is presented to help screen readers follow lengthy + discussion threads. You can hide this from sighted users using the class + visually-hidden. #} - {% if parent %} -

{{ parent }}

+ {% if parent_comment %} +

{{ 'In reply to !parent_title by !parent_author'|t({ '!parent_title': parent_title, '!parent_author': parent_author }) }}

{% endif %} {{ permalink }} diff --git a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php b/core/modules/history/src/Tests/Views/HistoryTimestampTest.php index f711d33..252d24c 100644 --- a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php +++ b/core/modules/history/src/Tests/Views/HistoryTimestampTest.php @@ -43,7 +43,7 @@ public function testHandlers() { $account = $this->drupalCreateUser(); $this->drupalLogin($account); - \Drupal::currentUser()->setAccount($account); + $GLOBALS['user'] = $account; db_insert('history') ->fields(array( diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index e042b31..05467d2 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -649,7 +649,7 @@ protected function drupalCreateRole(array $permissions, $rid = NULL, $name = NUL * TRUE if the permissions are valid, FALSE otherwise. */ protected function checkPermissions(array $permissions) { - $available = array_keys(\Drupal::service('user.permissions')->getPermissions()); + $available = array_keys(\Drupal::moduleHandler()->invokeAll('permission')); $valid = TRUE; foreach ($permissions as $permission) { if (!in_array($permission, $available)) { diff --git a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php index 6580e57..0d06e7a 100644 --- a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php @@ -32,7 +32,7 @@ class BreadcrumbTest extends MenuTestBase { protected function setUp() { parent::setUp(); - $perms = array_keys(\Drupal::service('user.permissions')->getPermissions()); + $perms = array_keys(\Drupal::moduleHandler()->invokeAll('permission')); $this->admin_user = $this->drupalCreateUser($perms); $this->drupalLogin($this->admin_user); diff --git a/core/modules/system/src/Tests/System/AdminTest.php b/core/modules/system/src/Tests/System/AdminTest.php index 546b62c..8ed747a 100644 --- a/core/modules/system/src/Tests/System/AdminTest.php +++ b/core/modules/system/src/Tests/System/AdminTest.php @@ -45,7 +45,7 @@ protected function setUp() { // Create an administrator with all permissions, as well as a regular user // who can only access administration pages and perform some Locale module // administrative tasks, but not all of them. - $this->admin_user = $this->drupalCreateUser(array_keys(\Drupal::service('user.permissions')->getPermissions())); + $this->admin_user = $this->drupalCreateUser(array_keys(\Drupal::moduleHandler()->invokeAll('permission'))); $this->web_user = $this->drupalCreateUser(array( 'access administration pages', 'translate interface', diff --git a/core/modules/user/src/Form/UserPermissionsForm.php b/core/modules/user/src/Form/UserPermissionsForm.php index 83408d6..bf34063 100644 --- a/core/modules/user/src/Form/UserPermissionsForm.php +++ b/core/modules/user/src/Form/UserPermissionsForm.php @@ -8,9 +8,9 @@ namespace Drupal\user\Form; use Drupal\Component\Utility\String; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\user\PermissionHandlerInterface; use Drupal\user\RoleStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -20,11 +20,11 @@ class UserPermissionsForm extends FormBase { /** - * The permission handler. + * The module handler. * - * @var \Drupal\user\PermissionHandlerInterface + * @var \Drupal\Core\Extension\ModuleHandlerInterface */ - protected $permissionHandler; + protected $moduleHandler; /** * The role storage. @@ -36,13 +36,13 @@ class UserPermissionsForm extends FormBase { /** * Constructs a new UserPermissionsForm. * - * @param \Drupal\user\PermissionHandlerInterface $permission_handler - * The permission handler. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. * @param \Drupal\user\RoleStorageInterface $role_storage * The role storage. */ - public function __construct(PermissionHandlerInterface $permission_handler, RoleStorageInterface $role_storage) { - $this->permissionHandler = $permission_handler; + public function __construct(ModuleHandlerInterface $module_handler, RoleStorageInterface $role_storage) { + $this->moduleHandler = $module_handler; $this->roleStorage = $role_storage; } @@ -51,7 +51,7 @@ public function __construct(PermissionHandlerInterface $permission_handler, Role */ public static function create(ContainerInterface $container) { return new static( - $container->get('user.permissions'), + $container->get('module_handler'), $container->get('entity.manager')->getStorage('user_role') ); } @@ -96,6 +96,14 @@ public function buildForm(array $form, FormStateInterface $form_state) { $module_info = system_rebuild_module_data(); $hide_descriptions = system_admin_compact_mode(); + // Get a list of all the modules implementing a hook_permission() and sort by + // display name. + $modules = array(); + foreach ($this->moduleHandler->getImplementations('permission') as $module) { + $modules[$module] = $module_info[$module]->info['name']; + } + asort($modules); + $form['system_compact_link'] = array( '#theme' => 'system_compact_link', ); @@ -113,59 +121,55 @@ public function buildForm(array $form, FormStateInterface $form_state) { ); } - $permissions = $this->permissionHandler->getPermissions(); - $permissions_by_provider = array(); - foreach ($permissions as $permission_name => $permission) { - $permissions_by_provider[$permission['provider']][$permission_name] = $permission; - } - - foreach ($permissions_by_provider as $provider => $permissions) { - // Module name. - $form['permissions'][$provider] = array(array( - '#wrapper_attributes' => array( - 'colspan' => count($role_names) + 1, - 'class' => array('module'), - 'id' => 'module-' . $provider, - ), - '#markup' => $module_info[$provider]->info['name'], - )); - foreach ($permissions as $perm => $perm_item) { - // Fill in default values for the permission. - $perm_item += array( - 'description' => '', - 'restrict access' => FALSE, - 'warning' => !empty($perm_item['restrict access']) ? $this->t('Warning: Give to trusted roles only; this permission has security implications.') : '', - ); - $options[$perm] = $perm_item['title']; - // Show the permission description. - if (!$hide_descriptions) { - $user_permission_description = $perm_item['description']; - // Append warning message. - if (!empty($perm_item['warning'])) { - $user_permission_description .= ' ' . $perm_item['warning'] . ''; - } - } - $form['permissions'][$perm]['description'] = array( + foreach ($modules as $module => $display_name) { + if ($permissions = $this->moduleHandler->invoke($module, 'permission')) { + // Module name. + $form['permissions'][$module] = array(array( '#wrapper_attributes' => array( - 'class' => array('permission'), + 'colspan' => count($role_names) + 1, + 'class' => array('module'), + 'id' => 'module-' . $module, ), - '#type' => 'item', - '#markup' => $perm_item['title'], - '#description' => $user_permission_description, - ); - $options[$perm] = ''; - foreach ($role_names as $rid => $name) { - $form['permissions'][$perm][$rid] = array( - '#title' => $name . ': ' . $perm_item['title'], - '#title_display' => 'invisible', + '#markup' => $module_info[$module]->info['name'], + )); + foreach ($permissions as $perm => $perm_item) { + // Fill in default values for the permission. + $perm_item += array( + 'description' => '', + 'restrict access' => FALSE, + 'warning' => !empty($perm_item['restrict access']) ? $this->t('Warning: Give to trusted roles only; this permission has security implications.') : '', + ); + $options[$perm] = $perm_item['title']; + // Show the permission description. + if (!$hide_descriptions) { + $user_permission_description = $perm_item['description']; + // Append warning message. + if (!empty($perm_item['warning'])) { + $user_permission_description .= ' ' . $perm_item['warning'] . ''; + } + } + $form['permissions'][$perm]['description'] = array( '#wrapper_attributes' => array( - 'class' => array('checkbox'), + 'class' => array('permission'), ), - '#type' => 'checkbox', - '#default_value' => in_array($perm, $role_permissions[$rid]) ? 1 : 0, - '#attributes' => array('class' => array('rid-' . $rid)), - '#parents' => array($rid, $perm), + '#type' => 'item', + '#markup' => $perm_item['title'], + '#description' => $user_permission_description, ); + $options[$perm] = ''; + foreach ($role_names as $rid => $name) { + $form['permissions'][$perm][$rid] = array( + '#title' => $name . ': ' . $perm_item['title'], + '#title_display' => 'invisible', + '#wrapper_attributes' => array( + 'class' => array('checkbox'), + ), + '#type' => 'checkbox', + '#default_value' => in_array($perm,$role_permissions[$rid]) ? 1 : 0, + '#attributes' => array('class' => array('rid-' . $rid)), + '#parents' => array($rid, $perm), + ); + } } } } diff --git a/core/modules/user/src/PermissionHandler.php b/core/modules/user/src/PermissionHandler.php deleted file mode 100644 index c396bcf..0000000 --- a/core/modules/user/src/PermissionHandler.php +++ /dev/null @@ -1,188 +0,0 @@ -moduleHandler = $module_handler; - $this->stringTranslation = $string_translation; - } - - /** - * Gets the YAML discovery. - * - * @return \Drupal\Component\Discovery\YamlDiscovery - * The YAML discovery. - */ - protected function getYamlDiscovery() { - if (!isset($this->yamlDiscovery)) { - $this->yamlDiscovery = new YamlDiscovery('permissions', $this->moduleHandler->getModuleDirectories()); - } - return $this->yamlDiscovery; - } - - /** - * {@inheritdoc} - */ - public function getPermissions() { - $all_permissions = $this->buildPermissionsYaml(); - - $all_permissions += $this->buildPermissionsModules(); - - return $this->sortPermissionsByProviderName($all_permissions); - } - - /** - * Builds all permissions provided by .permissions.yml files. - * - * @return array[] - * Each return permission is an array with the following keys: - * - title: The title of the permission. - * - description: The description of the permission, defaults to NULL. - * - provider: The provider of the permission. - */ - protected function buildPermissionsYaml() { - $all_permissions = array(); - foreach ($this->getYamlDiscovery()->findAll() as $provider => $permissions) { - foreach ($permissions as &$permission) { - if (!is_array($permission)) { - $permission = array( - 'title' => $permission, - ); - } - $permission['title'] = $this->t($permission['title']); - $permission['description'] = isset($permission['description']) ? $this->t($permission['description']) : NULL; - $permission['provider'] = $provider; - } - $all_permissions += $permissions; - } - return $all_permissions; - } - - /** - * Builds all permissions provided by .module files. - * - * @return array[] - * Each return permission is an array with the following keys: - * - title: The title of the permission. - * - description: The description of the permission, defaults to NULL. - * - provider: The provider of the permission. - */ - protected function buildPermissionsModules() { - $all_permissions = array(); - foreach ($this->moduleHandler->getImplementations('permission') as $provider) { - $permissions = $this->moduleHandler->invoke($provider, 'permission'); - foreach ($permissions as &$permission) { - if (!is_array($permission)) { - $permission = array( - 'title' => $permission, - 'description' => NULL,`` - ); - } - $permission['provider'] = $provider; - } - $all_permissions += $permissions; - } - return $all_permissions; - } - - /** - * Sorts the given permissions by provider name. - * - * @param array $all_permissions - * The permissions to be sorted. - * - * @return array[] - * Each return permission is an array with the following keys: - * - title: The title of the permission. - * - description: The description of the permission, defaults to NULL. - * - provider: The provider of the permission. - */ - protected function sortPermissionsByProviderName(array $all_permissions = array()) { - // Get a list of all the modules providing permissions and sort by - // display name. - $modules = $this->getModuleNames(); - - uasort($all_permissions, function (array $permission_a, array $permission_b) use ($modules) { - return $modules[$permission_a['provider']] > $modules[$permission_b['provider']]; - }); - return $all_permissions; - } - - /** - * Returns all module names. - * - * @return string[] - * Returns the human readable names of all modules keyed by machine name. - */ - protected function getModuleNames() { - $modules = array(); - $module_info = $this->systemRebuildModuleData(); - foreach (array_keys($this->moduleHandler->getModuleList()) as $module) { - $modules[$module] = $module_info[$module]->info['name']; - } - asort($modules); - return $modules; - } - - /** - * Wraps system_rebuild_module_data() - * - * @return \Drupal\Core\Extension\Extension[] - */ - protected function systemRebuildModuleData() { - return system_rebuild_module_data(); - } - -} diff --git a/core/modules/user/src/PermissionHandlerInterface.php b/core/modules/user/src/PermissionHandlerInterface.php deleted file mode 100644 index 5259245..0000000 --- a/core/modules/user/src/PermissionHandlerInterface.php +++ /dev/null @@ -1,47 +0,0 @@ -getPermissions(); + $permissions = \Drupal::moduleHandler()->invokeAll('permission'); if (isset($permissions[$this->options['perm']])) { return $permissions[$this->options['perm']]['title']; } diff --git a/core/modules/user/src/Plugin/views/field/Permissions.php b/core/modules/user/src/Plugin/views/field/Permissions.php index ee4fd0c..92d7171 100644 --- a/core/modules/user/src/Plugin/views/field/Permissions.php +++ b/core/modules/user/src/Plugin/views/field/Permissions.php @@ -83,7 +83,7 @@ public function preRender(&$values) { $uids = array(); $this->items = array(); - $permission_names = \Drupal::service('user.permissions')->getPermissions(); + $permission_names = \Drupal::moduleHandler()->invokeAll('permission'); $rids = array(); foreach ($values as $result) { diff --git a/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php b/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php index f28565e..0a3f439 100644 --- a/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php +++ b/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php @@ -29,16 +29,17 @@ public function test_plugin_argument_default_current_user() { // Switch the user, we have to check the global user too, because drupalLogin is only for the simpletest browser. $this->drupalLogin($account); - $admin = \Drupal::currentUser(); + global $user; + $admin = $user; $session_manager = \Drupal::service('session_manager')->disable(); - \Drupal::currentUser()->setAccount($account); + $user = $account; $view = Views::getView('test_plugin_argument_default_current_user'); $view->initHandlers(); $this->assertEqual($view->argument['null']->getDefaultArgument(), $account->id(), 'Uid of the current user is used.'); // Switch back. - \Drupal::currentUser()->setAccount($admin); + $user = $admin; $session_manager->enable(); } diff --git a/core/modules/user/tests/src/PermissionHandlerTest.php b/core/modules/user/tests/src/PermissionHandlerTest.php deleted file mode 100644 index 8856dd8..0000000 --- a/core/modules/user/tests/src/PermissionHandlerTest.php +++ /dev/null @@ -1,227 +0,0 @@ -stringTranslation = $this->getStringTranslationStub(); - } - - /** - * Provides an extension object for a given module with a human name. - * - * @param string $module - * The module machine name. - * @param string $name - * The module human name. - * - * @return \Drupal\Core\Extension\Extension - * The extension object. - */ - protected function mockModuleExtension($module, $name) { - $extension = new Extension($module, "modules/$module"); - $extension->info['name'] = $name; - return $extension; - } - - /** - * Tests permissions by hook_permission. - * - * @covers ::__construct - * @covers ::getPermissions - * @covers ::buildPermissions - * @covers ::buildPermissionsModules - * @covers ::sortPermissionsByProviderName - * @covers ::getModuleNames - */ - public function testBuildPermissionsModules() { - $modules = array('module_a', 'module_b', 'module_c'); - $extensions = array( - 'module_a' => $this->mockModuleExtension('module_a', 'Module a'), - 'module_b' => $this->mockModuleExtension('module_b', 'Moduleb'), - 'module_c' => $this->mockModuleExtension('module_c', 'Module c'), - ); - $permissions = array( - 'module_a' => array('access_module_a' => 'single_description'), - 'module_b' => array('access module b' => array('title' => 'Access B', 'description' => 'bla bla')), - 'module_c' => array('access_module_c' => array('title' => 'Access C', 'description' => 'bla bla', 'restrict access' => TRUE)), - ); - $this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); - $this->moduleHandler->expects($this->once()) - ->method('getModuleDirectories') - ->willReturn([]); - - $this->moduleHandler->expects($this->at(1)) - ->method('getImplementations') - ->with('permission') - ->willReturn($modules); - - // Setup the module handler. - $i = 2; - foreach ($modules as $module_name) { - $this->moduleHandler->expects($this->at($i++)) - ->method('invoke') - ->with($module_name) - ->willReturn($permissions[$module_name]); - } - $this->moduleHandler->expects($this->any()) - ->method('getModuleList') - ->willReturn(array_flip($modules)); - - $this->permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation); - - // Setup system_rebuild_module_data(). - $this->permissionHandler->setSystemRebuildModuleData($extensions); - - $actual_permissions = $this->permissionHandler->getPermissions(); - $this->assertPermissions($actual_permissions); - // Ensure that the human name of the module is taken into account for the - // sorting. - $this->assertSame(array('access_module_a', 'access_module_c', 'access module b'), array_keys($actual_permissions)); - } - - /** - * Tests permissions provided by YML files. - * - * @covers ::__construct - * @covers ::getPermissions - * @covers ::buildPermissions - * @covers ::buildPermissionsYaml - */ - public function testBuildPermissionsYaml() { - vfsStreamWrapper::register(); - $root = new vfsStreamDirectory('modules'); - vfsStreamWrapper::setRoot($root); - - $this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); - $this->moduleHandler->expects($this->once()) - ->method('getModuleDirectories') - ->willReturn(array( - 'module_a' => vfsStream::url('modules/module_a'), - 'module_b' => vfsStream::url('modules/module_b'), - 'module_c' => vfsStream::url('modules/module_c'), - )); - - $url = vfsStream::url('modules'); - mkdir($url . '/module_a'); - file_put_contents($url . '/module_a/module_a.permissions.yml', -"access_module_a: single_description" - ); - mkdir($url . '/module_b'); - file_put_contents($url . '/module_b/module_b.permissions.yml', -"'access module b': - title: 'Access B' - description: 'bla bla' -"); - mkdir($url . '/module_c'); - file_put_contents($url . '/module_c/module_c.permissions.yml', -"'access_module_c': - title: 'Access C' - description: 'bla bla' - 'restrict access': TRUE -"); - $modules = array('module_a', 'module_b', 'module_c'); - $extensions = array( - 'module_a' => $this->mockModuleExtension('module_a', 'Module a'), - 'module_b' => $this->mockModuleExtension('module_b', 'Module b'), - 'module_c' => $this->mockModuleExtension('module_c', 'Module c'), - ); - $this->moduleHandler->expects($this->any()) - ->method('getImplementations') - ->with('permission') - ->willReturn(array()); - - $this->moduleHandler->expects($this->any()) - ->method('getModuleList') - ->willReturn(array_flip($modules)); - - $this->permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation); - - // Setup system_rebuild_module_data(). - $this->permissionHandler->setSystemRebuildModuleData($extensions); - - $actual_permissions = $this->permissionHandler->getPermissions(); - $this->assertPermissions($actual_permissions); - } - - /** - * Checks that the permissions are like expected. - * - * @param array $actual_permissions - * The actual permissions - */ - protected function assertPermissions(array $actual_permissions) { - $this->assertCount(3, $actual_permissions); - $this->assertEquals($actual_permissions['access_module_a']['title'], 'single_description'); - $this->assertEquals($actual_permissions['access_module_a']['provider'], 'module_a'); - $this->assertEquals($actual_permissions['access module b']['title'], 'Access B'); - $this->assertEquals($actual_permissions['access module b']['provider'], 'module_b'); - $this->assertEquals($actual_permissions['access_module_c']['title'], 'Access C'); - $this->assertEquals($actual_permissions['access_module_c']['provider'], 'module_c'); - $this->assertEquals($actual_permissions['access_module_c']['restrict access'], TRUE); - } - -} - -class TestPermissionHandler extends PermissionHandler { - - /** - * Test module data. - * - * @var array - */ - protected $systemModuleData; - - protected function systemRebuildModuleData() { - return $this->systemModuleData; - } - - public function setSystemRebuildModuleData(array $extensions) { - $this->systemModuleData = $extensions; - } - -} diff --git a/core/modules/user/user.services.yml b/core/modules/user/user.services.yml index 7ccd7be..852a983 100644 --- a/core/modules/user/user.services.yml +++ b/core/modules/user/user.services.yml @@ -59,9 +59,6 @@ services: arguments: ['@serialization.phpserialize', '@database', '@lock', '%user.tempstore.expire%'] tags: - { name: backend_overridable } - user.permissions: - class: Drupal\user\PermissionHandler - arguments: ['@module_handler', '@string_translation'] parameters: user.tempstore.expire: 604800 diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 459ff0a..3294836 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -293,6 +293,19 @@ function views_theme_suggestions_comment_alter(array &$suggestions, array $varia } /** + * Implements hook_permission(). + */ +function views_permission() { + return array( + 'access all views' => array( + 'title' => t('Bypass views access control'), + 'description' => t('Bypass access control when accessing views.'), + 'restrict access' => TRUE, + ), + ); +} + +/** * Implements hook_page_alter(). */ function views_page_alter(&$page) { diff --git a/core/modules/views/views.permissions.yml b/core/modules/views/views.permissions.yml deleted file mode 100644 index db47ea5..0000000 --- a/core/modules/views/views.permissions.yml +++ /dev/null @@ -1,4 +0,0 @@ -'access all views': - title: 'Bypass views access control' - description: 'Bypass access control when accessing views.' - 'restrict access': TRUE diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module index f22299e..1bec041 100644 --- a/core/modules/views_ui/views_ui.module +++ b/core/modules/views_ui/views_ui.module @@ -125,6 +125,19 @@ function views_ui_theme() { } /** + * Implements hook_permission(). + */ +function views_ui_permission() { + return array( + 'administer views' => array( + 'title' => t('Administer views'), + 'description' => t('Access the views administration pages.'), + 'restrict access' => TRUE, + ), + ); +} + +/** * Implements hook_preprocess_HOOK() for views templates. */ function views_ui_preprocess_views_view(&$variables) { diff --git a/core/modules/views_ui/views_ui.permissions.yml b/core/modules/views_ui/views_ui.permissions.yml deleted file mode 100644 index 0881aab..0000000 --- a/core/modules/views_ui/views_ui.permissions.yml +++ /dev/null @@ -1,4 +0,0 @@ -'administer views': - title: 'Administer views' - description: 'Access the views administration pages.' - 'restrict access': TRUE diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install index 98c279f..6ea9c05 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -34,7 +34,7 @@ function standard_install() { user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access comments', 'post comments', 'skip comment approval')); // Enable all permissions for the administrator role. - user_role_grant_permissions('administrator', array_keys(\Drupal::service('user.permissions')->getPermissions())); + user_role_grant_permissions('administrator', array_keys(\Drupal::moduleHandler()->invokeAll('permission'))); // Set this as the administrator role. $user_settings->set('admin_role', 'administrator')->save(); diff --git a/core/themes/bartik/templates/comment.html.twig b/core/themes/bartik/templates/comment.html.twig index c00a9c5..5c942c3 100644 --- a/core/themes/bartik/templates/comment.html.twig +++ b/core/themes/bartik/templates/comment.html.twig @@ -43,21 +43,16 @@ * * These variables are provided to give context about the parent comment (if * any): - * - comment_parent: Full parent comment entity (if any). + * - parent_comment: Full parent comment entity (if any). * - parent_author: Equivalent to author for the parent comment. * - parent_created: Equivalent to created for the parent comment. * - parent_changed: Equivalent to changed for the parent comment. * - parent_title: Equivalent to title for the parent comment. * - parent_permalink: Equivalent to permalink for the parent comment. - * - parent: A text string of parent comment submission information created from - * 'parent_author' and 'parent_created' during template_preprocess_comment(). - * This information is presented to help screen readers follow lengthy - * discussion threads. You can hide this from sighted users using the class - * visually-hidden. * * These two variables are provided for context: * - comment: Full comment object. - * - entity: Entity the comments are attached to. + * - commented_entity: Entity the comments are attached to. * * @see template_preprocess_comment() */ @@ -79,13 +74,16 @@ {{ permalink }}

{# - // Indicate the semantic relationship between parent and child comments - // for accessibility. The list is difficult to navigate in a screen - // reader without this information. + Indicate the semantic relationship between parent and child comments + for accessibility. The list is difficult to navigate in a screen + reader without this information. + This information is presented to help screen readers follow lengthy + discussion threads. You can hide this from sighted users using the class + visually-hidden. #} - {% if parent %} + {% if parent_comment %}

- {{ parent }} + {{ 'In reply to !parent_title by !parent_author'|t({ '!parent_title': parent_title, '!parent_author': parent_author }) }}

{% endif %}