private function AuthorPaneBlock::findAuthor in Author Pane 8.3
Attempts to find the author for the current page.
Return value
\Drupal\user\UserInterface The author user entity.
1 call to AuthorPaneBlock::findAuthor()
- AuthorPaneBlock::build in src/
Plugin/ Block/ AuthorPaneBlock.php - Builds and returns the renderable array for this block plugin.
File
- src/
Plugin/ Block/ AuthorPaneBlock.php, line 101 - Contains \Drupal\author_pane\Plugin\Block\AuthorPane.
Class
- AuthorPaneBlock
- Provides a Author Pane block.
Namespace
Drupal\author_pane\Plugin\BlockCode
private function findAuthor() {
// Check if we are on a profile page.
$author = \Drupal::request()->attributes
->get('user');
if (!is_null($author)) {
return $author;
}
// Check if there is a node context we can pull the author from.
$node = $this
->getContextValue('node');
if (!is_null($node)) {
return $node
->getOwner();
}
// @TODO: Figure out how to make this work in other situations.
// No source found for the author.
return NULL;
}