EditorNoteController.php in Editor Notes 8
Namespace
Drupal\editor_note\ControllerFile
src/Controller/EditorNoteController.phpView source
<?php
namespace Drupal\editor_note\Controller;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\editor_note\Entity\EditorNote;
/**
* Checks access for editor note routes.
*
* @package Drupal\editor_note\Controller
*/
class EditorNoteController {
/**
* Checks access to editor note.
*
* @param \Drupal\Core\Session\AccountInterface $account
* Current user.
* @param \Drupal\editor_note\Entity\EditorNote $editor_note
* Editor note entity.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
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;
}
}
Classes
Name![]() |
Description |
---|---|
EditorNoteController | Checks access for editor note routes. |