public function EditorNoteController::accessEditorNote in Editor Notes 8
Checks access to editor note.
Parameters
\Drupal\Core\Session\AccountInterface $account: Current user.
\Drupal\editor_note\Entity\EditorNote $editor_note: Editor note entity.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
1 string reference to 'EditorNoteController::accessEditorNote'
File
- src/
Controller/ EditorNoteController.php, line 27
Class
- EditorNoteController
- Checks access for editor note routes.
Namespace
Drupal\editor_note\ControllerCode
public function accessEditorNote(AccountInterface $account, EditorNote $editor_note = NULL) {
if (!empty($editor_note)) {
$note_author = $editor_note->uid->entity;
if (!empty($note_author) && $note_author
->id() == $account
->id()) {
$access_result = AccessResult::allowed();
}
else {
$access_result = AccessResult::allowedIf($account
->hasPermission('administer any editor note'));
}
}
else {
$access_result = AccessResult::forbidden();
}
return $access_result;
}