Drupal 8  8.0.2
NodeRouteContext Class Reference
Inheritance diagram for NodeRouteContext:

Public Member Functions

 __construct (RouteMatchInterface $route_match)
 
 getRuntimeContexts (array $unqualified_context_ids)
 
 getAvailableContexts ()
 

Protected Attributes

 $routeMatch
 

Detailed Description

Sets the current node as a context on node routes.

Constructor & Destructor Documentation

__construct ( RouteMatchInterface  $route_match)

Constructs a new NodeRouteContext.

Parameters
\Drupal\Core\Routing\RouteMatchInterface$route_matchThe route match object.

References Drupal\routeMatch().

Here is the call graph for this function:

Member Function Documentation

getAvailableContexts ( )

{Gets all available contexts for the purposes of configuration.When a context aware plugin is being configured, the configuration UI must know which named contexts are potentially available, but does not care about the value, since the value can be different for each request, and might not be available at all during the configuration UI's request.For example:

// During configuration, there is no specific node to pass as context.
// However, inform the system that a context named 'node' is
// available, and provide its definition, so that context aware plugins
// can be configured to use it. When the plugin, for example a block,
// needs to evaluate the context, the value of this context will be
// supplied by getRuntimeContexts().
$context = new Context(new ContextDefinition('entity:node'));
return ['node' => $context];
Returns
[] All available contexts keyed by the unqualified context ID.
See Also
::getRuntimeContext()
}

Implements ContextProviderInterface.

References t().

Here is the call graph for this function:

getRuntimeContexts ( array  $unqualified_context_ids)

{Gets runtime context values for the given context IDs.For context-aware plugins to function correctly, all of the contexts that they require must be populated with values. So this method should set a value for each context that it adds. For example:

// Determine a specific node to pass as context to a block.
$node = ...
// Set that specific node as the value of the 'node' context.
$context = new Context(new ContextDefinition('entity:node'), $node);
return ['node' => $context];
On the other hand, there are cases, on which providers no longer are possible to provide context objects, even without the value, so the caller should not expect it.
Parameters
string[]$unqualified_context_ids The requested context IDs. The context provider must only return contexts for those IDs.
Returns
[] The determined available contexts, keyed by the unqualified context_id.
See Also
:getAvailableContexts()
}

Implements ContextProviderInterface.

References Entity\create(), and Drupal\routeMatch().

Here is the call graph for this function:


The documentation for this class was generated from the following file: