Skip to content
Snippets Groups Projects
Commit f0e3932e authored by Eric Bremner's avatar Eric Bremner Committed by Lily Yan
Browse files

ISTWCMS-4093: adding comments and cleaning up code

parent 209f10f6
No related branches found
No related tags found
No related merge requests found
...@@ -25,11 +25,19 @@ class UwNodeAccessCheck implements AccessInterface { ...@@ -25,11 +25,19 @@ class UwNodeAccessCheck implements AccessInterface {
* The access result. * The access result.
*/ */
public function access(RouteMatchInterface $route_match, AccountInterface $account) { public function access(RouteMatchInterface $route_match, AccountInterface $account) {
// Get the node object, which is in the route match variable.
$node = $route_match->getParameter('node'); $node = $route_match->getParameter('node');
// Check if this is a sidebar content type and if the user has permission to edit the content type.
// We want to throw a 404 (NotFoundHttpException) if they do not have access. This is the case when
// a user is not logged in, and when they do not have permission to edit it.
if ($node && $node->bundle() == 'uw_ct_sidebar' && !$account->hasPermission('edit any uw_ct_sidebar content')) { if ($node && $node->bundle() == 'uw_ct_sidebar' && !$account->hasPermission('edit any uw_ct_sidebar content')) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
// We have to return some type of access, so we are going to return allowed, if they do not have access,
// the new exception is going to be thrown above.
return AccessResult::allowed(); return AccessResult::allowed();
} }
} }
...@@ -5,8 +5,3 @@ uw_contact_access.form: ...@@ -5,8 +5,3 @@ uw_contact_access.form:
_form: '\Drupal\uw_cfg_common\Form\UwContentAccessForm' _form: '\Drupal\uw_cfg_common\Form\UwContentAccessForm'
requirements: requirements:
_permission: 'access content access form' _permission: 'access content access form'
#uw_node_access.node:
# pattern: '/node/{nid}'
# arguments: ['@current_user']
# requirements:
# _uw_node_access_check: 'TRUE'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment