Loading modules/sitewide_alert_block/src/Plugin/Block/SitewideAlertBlock.php +4 −4 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ use Drupal\Core\Block\BlockBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\sitewide_alert\SitewideAlertRenderer; use Drupal\sitewide_alert\SitewideAlertRendererInterface; /** * Implements SiteAlertBlock class. Loading @@ -21,7 +21,7 @@ class SitewideAlertBlock extends BlockBase implements ContainerFactoryPluginInte /** * The alert placeholder rendering service. * * @var \Drupal\sitewide_alert\SitewideAlertRender * @var \Drupal\sitewide_alert\SitewideAlertRendererInterface */ protected $renderer; Loading @@ -34,10 +34,10 @@ class SitewideAlertBlock extends BlockBase implements ContainerFactoryPluginInte * Block plugin id. * @param mixed $plugin_definition * Block plugin configuration. * @param \Drupal\sitewide_alert\SitewideAlertRenderer $renderer * @param \Drupal\sitewide_alert\SitewideAlertRendererInterface $renderer * Alert placeholder rendering service. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, SitewideAlertRenderer $renderer) { public function __construct(array $configuration, $plugin_id, $plugin_definition, SitewideAlertRendererInterface $renderer) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->renderer = $renderer; } Loading sitewide_alert.install +19 −3 Original line number Diff line number Diff line Loading @@ -5,14 +5,18 @@ * Install, update and uninstall functions for the sitewide_alert module. */ use Drupal\Core\Session\AccountInterface; use Drupal\user\Entity\Role; use Drupal\user\RoleInterface; /** * Implements hook_install(). */ function sitewide_alert_install() { // By default allow anonymous users to view Sitewide Alerts. user_role_grant_permissions(AccountInterface::ANONYMOUS_ROLE, ['view published sitewide alert entities']); // Grant the "view published sitewide alert entities" permission to all users by default. if (\Drupal::moduleHandler()->moduleExists('user')) { user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['view published sitewide alert entities']); user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['view published sitewide alert entities']); } } /** Loading Loading @@ -50,6 +54,18 @@ function sitewide_alert_update_9001() { } } /** * Add the 'view published sitewide alert entities' permission for roles that * have the 'access content' permission. */ function sitewide_alert_update_9002() { foreach (array_filter(Role::loadMultiple(), static fn($role) => $role->hasPermission('access content')) as $role) { $role ->grantPermission('view published sitewide alert entities') ->save(); } } /** * Rename the 'revision_log_message' revision metadata key in the entity type. * Loading sitewide_alert.links.task.yml +0 −5 Original line number Diff line number Diff line Loading @@ -11,11 +11,6 @@ entity.sitewide_alert.collection: entity.sitewide_alert.canonical: route_name: entity.sitewide_alert.canonical base_route: entity.sitewide_alert.canonical title: 'View' entity.sitewide_alert.edit_form: route_name: entity.sitewide_alert.edit_form base_route: entity.sitewide_alert.canonical title: 'Edit' entity.sitewide_alert.version_history: Loading sitewide_alert.permissions.yml +2 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,8 @@ edit sitewide alert entities: title: 'Edit Sitewide Alert entities' view published sitewide alert entities: title: 'View published Sitewide Alert entities' title: 'View published (active) Sitewide Alert entities' description: 'This permission should be given to all roles that should be able to see active alerts.' view unpublished sitewide alert entities: title: 'View unpublished Sitewide Alert entities' Loading sitewide_alert.routing.yml +21 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ sitewide_alert.sitewide_alerts_controller_load: _controller: '\Drupal\sitewide_alert\Controller\SitewideAlertsController::load' _title: 'load' requirements: _permission: 'access content' _permission: 'view published sitewide alert entities' entity.sitewide_alert.config_form: path: '/admin/config/sitewide_alerts' Loading @@ -15,3 +15,23 @@ entity.sitewide_alert.config_form: _permission: 'administer sitewide alert' options: _admin_route: TRUE entity.sitewide_alert.canonical: path: '/admin/content/sitewide_alert/{sitewide_alert}' defaults: _entity_form: 'sitewide_alert.edit' options: _admin_route: TRUE requirements: _entity_access: 'sitewide_alert.update' block_content: \d+ entity.sitewide_alert.edit_form: path: '/admin/content/sitewide_alert/{sitewide_alert}' defaults: _entity_form: 'sitewide_alert.edit' options: _admin_route: TRUE requirements: _entity_access: 'sitewide_alert.update' block_content: \d+ Loading
modules/sitewide_alert_block/src/Plugin/Block/SitewideAlertBlock.php +4 −4 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ use Drupal\Core\Block\BlockBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\sitewide_alert\SitewideAlertRenderer; use Drupal\sitewide_alert\SitewideAlertRendererInterface; /** * Implements SiteAlertBlock class. Loading @@ -21,7 +21,7 @@ class SitewideAlertBlock extends BlockBase implements ContainerFactoryPluginInte /** * The alert placeholder rendering service. * * @var \Drupal\sitewide_alert\SitewideAlertRender * @var \Drupal\sitewide_alert\SitewideAlertRendererInterface */ protected $renderer; Loading @@ -34,10 +34,10 @@ class SitewideAlertBlock extends BlockBase implements ContainerFactoryPluginInte * Block plugin id. * @param mixed $plugin_definition * Block plugin configuration. * @param \Drupal\sitewide_alert\SitewideAlertRenderer $renderer * @param \Drupal\sitewide_alert\SitewideAlertRendererInterface $renderer * Alert placeholder rendering service. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, SitewideAlertRenderer $renderer) { public function __construct(array $configuration, $plugin_id, $plugin_definition, SitewideAlertRendererInterface $renderer) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->renderer = $renderer; } Loading
sitewide_alert.install +19 −3 Original line number Diff line number Diff line Loading @@ -5,14 +5,18 @@ * Install, update and uninstall functions for the sitewide_alert module. */ use Drupal\Core\Session\AccountInterface; use Drupal\user\Entity\Role; use Drupal\user\RoleInterface; /** * Implements hook_install(). */ function sitewide_alert_install() { // By default allow anonymous users to view Sitewide Alerts. user_role_grant_permissions(AccountInterface::ANONYMOUS_ROLE, ['view published sitewide alert entities']); // Grant the "view published sitewide alert entities" permission to all users by default. if (\Drupal::moduleHandler()->moduleExists('user')) { user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['view published sitewide alert entities']); user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['view published sitewide alert entities']); } } /** Loading Loading @@ -50,6 +54,18 @@ function sitewide_alert_update_9001() { } } /** * Add the 'view published sitewide alert entities' permission for roles that * have the 'access content' permission. */ function sitewide_alert_update_9002() { foreach (array_filter(Role::loadMultiple(), static fn($role) => $role->hasPermission('access content')) as $role) { $role ->grantPermission('view published sitewide alert entities') ->save(); } } /** * Rename the 'revision_log_message' revision metadata key in the entity type. * Loading
sitewide_alert.links.task.yml +0 −5 Original line number Diff line number Diff line Loading @@ -11,11 +11,6 @@ entity.sitewide_alert.collection: entity.sitewide_alert.canonical: route_name: entity.sitewide_alert.canonical base_route: entity.sitewide_alert.canonical title: 'View' entity.sitewide_alert.edit_form: route_name: entity.sitewide_alert.edit_form base_route: entity.sitewide_alert.canonical title: 'Edit' entity.sitewide_alert.version_history: Loading
sitewide_alert.permissions.yml +2 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,8 @@ edit sitewide alert entities: title: 'Edit Sitewide Alert entities' view published sitewide alert entities: title: 'View published Sitewide Alert entities' title: 'View published (active) Sitewide Alert entities' description: 'This permission should be given to all roles that should be able to see active alerts.' view unpublished sitewide alert entities: title: 'View unpublished Sitewide Alert entities' Loading
sitewide_alert.routing.yml +21 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ sitewide_alert.sitewide_alerts_controller_load: _controller: '\Drupal\sitewide_alert\Controller\SitewideAlertsController::load' _title: 'load' requirements: _permission: 'access content' _permission: 'view published sitewide alert entities' entity.sitewide_alert.config_form: path: '/admin/config/sitewide_alerts' Loading @@ -15,3 +15,23 @@ entity.sitewide_alert.config_form: _permission: 'administer sitewide alert' options: _admin_route: TRUE entity.sitewide_alert.canonical: path: '/admin/content/sitewide_alert/{sitewide_alert}' defaults: _entity_form: 'sitewide_alert.edit' options: _admin_route: TRUE requirements: _entity_access: 'sitewide_alert.update' block_content: \d+ entity.sitewide_alert.edit_form: path: '/admin/content/sitewide_alert/{sitewide_alert}' defaults: _entity_form: 'sitewide_alert.edit' options: _admin_route: TRUE requirements: _entity_access: 'sitewide_alert.update' block_content: \d+