1 author_from_node.inc LayoutRelationshipAuthorFromNode::getContext(LayoutContext $source_context)

Get the context from this relationship.

Parameters

LayoutContext $source_context;: The source context on which this relationship is based.

Return value

LayoutContext|FALSE: The additional context added once this relationship is joined.

Overrides LayoutRelationship::getContext

File

core/modules/layout/plugins/relationships/author_from_node.inc, line 22
Provides relationship to relate the Author from a piece of content (node).

Class

LayoutRelationshipAuthorFromNode
@file Provides relationship to relate the Author from a piece of content (node).

Code

function getContext(LayoutContext $source_context) {
  $account = NULL;
  if (isset($source_context->data->uid)) {
    // Load the user that is the author of the node.
    $uid = $source_context->data->uid;
    $account = user_load($uid);
  }
  $user_context = layout_create_context('user', array(
    'position' => $source_context->position,
    'label' => $this->getAdminSummary(),
  ));
  $user_context->setData($account);

  return $user_context;
}