public function myTopicAccess(AccountInterface $account) {
    // Fetch user from url.
    $user = $this->requestStack->getCurrentRequest()->get('user');

    // If we don't have a user in the request, assume it's my own profile.
    if (is_null($user)) {
      // Usecase is the user menu, which is generated on all LU pages.
      $user = User::load($account->id());
    }

    // If not a user then just return neutral.
    if (!$user instanceof User) {
      $user = User::load($user);

      if (!$user instanceof User) {
        return AccessResult::neutral();
      }
    }

    // Own profile?
    if ($user->id() === $account->id()) {
      return AccessResult::allowedIfHasPermission($account, 'view topics on my profile');
    }
    return AccessResult::allowedIfHasPermission($account, 'view topics on other profiles');
  }
public function myTopicAccess(AccountInterface $account) {
    // Fetch user from url.
    $user = $this->requestStack->getCurrentRequest()->get('user');

    // If we don't have a user in the request, assume it's my own profile.
    if (is_null($user)) {
      // Usecase is the user menu, which is generated on all LU pages.
      $user = User::load($account->id());
    }

    // If not a user then just return neutral.
    if (!$user instanceof User) {
      $user = User::load($user);

      if (!$user instanceof User) {
        return AccessResult::neutral();
      }
    }

    // Own profile?
    if ($user->id() === $account->id()) {
      return AccessResult::allowedIfHasPermission($account, 'view topics on my profile');
    }
    return AccessResult::allowedIfHasPermission($account, 'view topics on other profiles');
  }
public function myTopicAccess ( AccountInterface $ account ) { // Fetch user from url. $ user = $ this -> requestStack -> getCurrentRequest ( ) -> get ( 'user' ) ; // If we don't have a user in the request, assume it's my own profile. if ( is_null ( $ user ) ) { // Usecase is the user menu, which is generated on all LU pages. $ user = User :: load ( $ account -> id ( ) ) ; } // If not a user then just return neutral. if ( ! $ user instanceof User ) { $ user = User :: load ( $ user ) ; if ( ! $ user instanceof User ) { return AccessResult :: neutral ( ) ; } } // Own profile? if ( $ user -> id ( ) === $ account -> id ( ) ) { return AccessResult :: allowedIfHasPermission ( $ account , 'view topics on my profile' ) ; } return AccessResult :: allowedIfHasPermission ( $ account , 'view topics on other profiles' ) ; }
Function that checks access on the my topic pages.

@param \Drupal\Core\Session\AccountInterface $account
The account we need to check access for.

@return \Drupal\Core\Access\AccessResult
If access is allowed.
Function that checks access on the my topic pages .