diff --git a/config/install/views.view.user_personal_notes.yml b/config/install/views.view.user_personal_notes.yml index 3ac9649ad31ec9c60c6f8f3620f90ba40be52546..81472ede8a8e67369526989e78c50abb7faae3a8 100644 --- a/config/install/views.view.user_personal_notes.yml +++ b/config/install/views.view.user_personal_notes.yml @@ -200,7 +200,7 @@ display: group_type: group admin_label: '' plugin_id: text_custom - empty: false + empty: true content: '<a href="/user/{{ arguments.user }}/add-note" class="button button--action button--primary">Add Note</a>' tokenize: true footer: { } diff --git a/src/Plugin/Block/PersonalNotesBlock.php b/src/Plugin/Block/PersonalNotesBlock.php index 471bbbdfb23a1d8b0ff45e62d265a6fcdde9ed0a..25e94ef6d8825f2f04cdd576013b00aa56aaf227 100644 --- a/src/Plugin/Block/PersonalNotesBlock.php +++ b/src/Plugin/Block/PersonalNotesBlock.php @@ -8,6 +8,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountProxyInterface; use Drupal\personal_notes\Entity\PersonalNote; +use Drupal\user\UserInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -79,7 +80,7 @@ class PersonalNotesBlock extends BlockBase implements ContainerFactoryPluginInte */ public function build(): array { // User must be logged on to have personal notes. - if (!$this->currentUser->isAnonymous()) { + if (!$this->currentUser->isAnonymous() && $this->routeMatch->getParameter('user') instanceof UserInterface) { $user = $this->routeMatch->getParameter('user');