class ThemeCompilerTargetContext in Theme Compiler 8
The context used to define common interface parameters for a theme compiler.
Hierarchy
- class \Drupal\theme_compiler\Plugin\ThemeCompilerTargetContext
Expanded class hierarchy of ThemeCompilerTargetContext
2 files declare their use of ThemeCompilerTargetContext
- RouteHelper.php in src/
Routing/ RouteHelper.php - ThemeCompilerController.php in src/
Controller/ ThemeCompilerController.php
File
- src/
Plugin/ ThemeCompilerTargetContext.php, line 8
Namespace
Drupal\theme_compiler\PluginView source
class ThemeCompilerTargetContext {
/**
* The fully-qualified method name used as the compiler route destination.
*
* @var string
*/
protected $compiler;
/**
* An array of compiler plugin target configuration options.
*
* @var array
*/
protected $options;
/**
* The theme-relative file system path to use for the compiler target.
*
* @var string
*/
protected $target;
/**
* The machine name of the theme to which this context belongs.
*
* @var string
*/
protected $theme;
/**
* Constructs a ThemeCompilerTargetContext.
*
* @param string $compiler
* The machine name of the compiler plugin to use.
* @param string $theme
* The machine name of the theme to which this context should belong.
* @param string $target
* The theme-relative file system path to use for the compiler target.
* @param array $options
* An array of compiler plugin target configuration options.
*/
public function __construct(string $compiler, string $theme, string $target, array $options) {
$this->compiler = $compiler;
$this->options = $options;
$this->target = ltrim($target, '/');
$this->theme = $theme;
}
/**
* Get the compiler for this context.
*
* @return string
* The machine name of the compiler plugin to use.
*/
public function getCompiler() {
return $this->compiler;
}
/**
* Get the options for this context.
*
* @return array
* An array of compiler plugin target configuration options.
*/
public function getOptions() {
return $this->options;
}
/**
* Get the theme for this context.
*
* @return string
* The machine name of the theme to which this context belongs.
*/
public function getTheme() {
return $this->theme;
}
/**
* Get the Uniform Resource Identifier path prefix for this context's theme.
*
* The output of this method is used to build Drupal route paths to files
* within this context's theme.
*
* @return string
* The Uniform Resource Identifier path prefix for this context's theme.
*/
public function getThemeUriPrefix() {
return '/' . drupal_get_path('theme', $this->theme);
}
/**
* Get the target for this context.
*
* @return string
* The theme-relative file system path to use for the compiler target.
*/
public function getTarget() {
return $this->target;
}
/**
* Compute a hash of the target for canonical identification purposes.
*
* @return string
* An identifier for the target of this context.
*/
public function getTargetId() {
return hash('sha256', $this
->getTargetUri());
}
/**
* Get the Uniform Resource Identifier path for this context's theme target.
*
* This method builds the target URI using the theme URI prefix and the
* theme-relative file system path used to represent the compiler target.
*
* @return string
* The Uniform Resource Identifier path for this context's theme target.
*/
public function getTargetUri() {
return $this
->getThemeUriPrefix() . '/' . $this->target;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ThemeCompilerTargetContext:: |
protected | property | The fully-qualified method name used as the compiler route destination. | |
ThemeCompilerTargetContext:: |
protected | property | An array of compiler plugin target configuration options. | |
ThemeCompilerTargetContext:: |
protected | property | The theme-relative file system path to use for the compiler target. | |
ThemeCompilerTargetContext:: |
protected | property | The machine name of the theme to which this context belongs. | |
ThemeCompilerTargetContext:: |
public | function | Get the compiler for this context. | |
ThemeCompilerTargetContext:: |
public | function | Get the options for this context. | |
ThemeCompilerTargetContext:: |
public | function | Get the target for this context. | |
ThemeCompilerTargetContext:: |
public | function | Compute a hash of the target for canonical identification purposes. | |
ThemeCompilerTargetContext:: |
public | function | Get the Uniform Resource Identifier path for this context's theme target. | |
ThemeCompilerTargetContext:: |
public | function | Get the theme for this context. | |
ThemeCompilerTargetContext:: |
public | function | Get the Uniform Resource Identifier path prefix for this context's theme. | |
ThemeCompilerTargetContext:: |
public | function | Constructs a ThemeCompilerTargetContext. |