Drupal 8  8.0.2
ThemeManager Class Reference
Inheritance diagram for ThemeManager:

Public Member Functions

 __construct ($root, ThemeNegotiatorInterface $theme_negotiator, ThemeInitializationInterface $theme_initialization, RequestStack $request_stack, ModuleHandlerInterface $module_handler)
 
 setThemeRegistry (Registry $theme_registry)
 
 getActiveTheme (RouteMatchInterface $route_match=NULL)
 
 hasActiveTheme ()
 
 resetActiveTheme ()
 
 setActiveTheme (ActiveTheme $active_theme)
 
 render ($hook, array $variables)
 
 alterForTheme (ActiveTheme $theme, $type, &$data, &$context1=NULL, &$context2=NULL)
 
 alter ($type, &$data, &$context1=NULL, &$context2=NULL)
 
- Public Member Functions inherited from ThemeManagerInterface
 getActiveTheme ()
 

Protected Member Functions

 initTheme (RouteMatchInterface $route_match=NULL)
 

Protected Attributes

 $themeNegotiator
 
 $themeRegistry
 
 $activeTheme
 
 $themeInitialization
 
 $requestStack
 
 $root
 

Detailed Description

Provides the default implementation of a theme manager.

Constructor & Destructor Documentation

__construct (   $root,
ThemeNegotiatorInterface  $theme_negotiator,
ThemeInitializationInterface  $theme_initialization,
RequestStack  $request_stack,
ModuleHandlerInterface  $module_handler 
)

Constructs a new ThemeManager object.

Parameters
string$rootThe app root.
\Drupal\Core\Theme\ThemeNegotiatorInterface$theme_negotiatorThe theme negotiator.
\Drupal\Core\Theme\ThemeInitializationInterface$theme_initializationThe theme initialization.
\Symfony\Component\HttpFoundation\RequestStack$request_stackThe request stack.
\Drupal\Core\Extension\ModuleHandlerInterface$module_handler

References Drupal\moduleHandler(), Drupal\requestStack(), and Drupal\root().

Here is the call graph for this function:

Member Function Documentation

alter (   $type,
$data,
$context1 = NULL,
$context2 = NULL 
)

{Passes alterable variables to specific $theme_TYPE_alter() implementations.It also invokes alter hooks for all base themes.$theme specifies the theme name of the active theme and all its base themes.This dispatch function hands off the passed-in variables to type-specific $theme_TYPE_alter() implementations in the active theme. It ensures a consistent interface for all altering operations.A maximum of 2 alterable arguments is supported. In case more arguments need to be passed and alterable, modules provide additional variables assigned by reference in the last $context argument:

$context = array(
'alterable' => &$alterable,
'unalterable' => $unalterable,
'foo' => 'bar',
);
$this->alter('mymodule_data', $alterable1, $alterable2, $context);
Note that objects are always passed by reference in PHP5. If it is absolutely required that no implementation alters a passed object in $context, then an object needs to be cloned:

$context = array(
'unalterable_object' => clone $object,
);
$this->alter('mymodule_data', $data, $context);
Parameters
string | array$typeA string describing the type of the alterable $data. 'form', 'links', 'node_content', and so on are several examples. Alternatively can be an array, in which case $theme_TYPE_alter() is invoked for each value in the array. When Form API is using $this->alter() to execute both $theme_form_alter() and $theme_form_FORM_ID_alter() implementations, it passes array('form', 'form_' . $form_id) for $type.
mixed$dataThe variable that will be passed to $theme_TYPE_alter() implementations to be altered. The type of this variable depends on the value of the $type argument. For example, when altering a 'form', $data will be a structured array. When altering a 'profile', $data will be an object.
mixed$context1(optional) An additional variable that is passed by reference.
mixed$context2(optional) An additional variable that is passed by reference. If more context needs to be provided to implementations, then this should be an associative array as described above. Execute the alter hook on the current theme.
See Also
}

Implements ThemeManagerInterface.

References ThemeManager\alterForTheme(), and ThemeManagerInterface\getActiveTheme().

Referenced by ThemeManager\render().

Here is the call graph for this function:

Here is the caller graph for this function:

alterForTheme ( ActiveTheme  $theme,
  $type,
$data,
$context1 = NULL,
$context2 = NULL 
)

{Provides an alter hook for a specific theme.Similar to ::alter, it also invokes the alter hooks for the base themes.

Parameters
\Drupal\Core\Theme\ActiveTheme$themeA manually specified theme.
string | array$typeA string describing the type of the alterable $data.
mixed$dataThe variable that will be passed to $theme_TYPE_alter() implementations
mixed$context1(optional) An additional variable that is passed by reference.
mixed$context2(optional) An additional variable that is passed by reference.
See Also
::alter
}

Todo:
Should we cache some of these information?

Implements ThemeManagerInterface.

References ActiveTheme\getBaseThemes(), and ActiveTheme\getName().

Referenced by ThemeManager\alter().

Here is the call graph for this function:

Here is the caller graph for this function:

getActiveTheme ( RouteMatchInterface  $route_match = NULL)

{}

References ThemeManager\initTheme().

Here is the call graph for this function:

hasActiveTheme ( )

{Determines whether there is an active theme.

Returns
bool
}

Implements ThemeManagerInterface.

initTheme ( RouteMatchInterface  $route_match = NULL)
protected

Initializes the active theme for a given route match.

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

References Drupal\routeMatch().

Referenced by ThemeManager\getActiveTheme().

Here is the call graph for this function:

Here is the caller graph for this function:

render (   $hook,
array  $variables 
)

{Generates themed output.See the Default theme implementations topic for details.

Parameters
string$hookThe name of the theme hook to call.
array$variablesAn associative array of theme variables.
Returns
string| The rendered output, or a Markup object.
}

Implements ThemeManagerInterface.

References ThemeManager\alter(), ThemeManagerInterface\getActiveTheme(), Drupal\logger(), Drupal\moduleHandler(), and Drupal\root().

Here is the call graph for this function:

resetActiveTheme ( )

{Resets the current active theme.Note: This method should not be used in common cases, just in special cases like tests.

Returns
$this
}

Implements ThemeManagerInterface.

setActiveTheme ( ActiveTheme  $active_theme)

{Sets the current active theme manually.Note: This method should not be used in common cases, just in special cases like tests.

Parameters
\Drupal\Core\Theme\ActiveTheme$active_themeThe new active theme.
Returns
$this
}

Implements ThemeManagerInterface.

setThemeRegistry ( Registry  $theme_registry)

Sets the theme registry.

Parameters
\Drupal\Core\Theme\Registry$theme_registryThe theme registry.
Returns
$this

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