class MarkdownParamConverter in Markdown 8.2
Parameter convertor for Markdown plugins.
Hierarchy
- class \Drupal\markdown\ParamConverter\MarkdownParamConverter implements ParamConverterInterface
Expanded class hierarchy of MarkdownParamConverter
1 string reference to 'MarkdownParamConverter'
1 service uses MarkdownParamConverter
File
- src/
ParamConverter/ MarkdownParamConverter.php, line 18
Namespace
Drupal\markdown\ParamConverterView source
class MarkdownParamConverter implements ParamConverterInterface {
/**
* The Config Factory service.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* The Markdown Allowed HTML Plugin Manager service.
*
* @var \Drupal\markdown\PluginManager\AllowedHtmlManager
*/
protected $allowedHtmlManager;
/**
* The Markdown Extension Plugin Manager service.
*
* @var \Drupal\markdown\PluginManager\ExtensionManagerInterface
*/
protected $extensionManager;
/**
* The Markdown Parser Plugin Manager service.
*
* @var \Drupal\markdown\PluginManager\ParserManagerInterface
*/
protected $parserManager;
/**
* MarkdownParamConverter constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The Config Factory service.
* @param \Drupal\markdown\PluginManager\ParserManagerInterface $parserManager
* The Markdown Parser Plugin Manager service.
* @param \Drupal\markdown\PluginManager\ExtensionManagerInterface $extensionManager
* The Markdown Extension Plugin Manager service.
* @param \Drupal\markdown\PluginManager\AllowedHtmlManager $allowedHtmlManager
* The Markdown Allowed HTML Plugin Manager service.
*/
public function __construct(ConfigFactoryInterface $configFactory, ParserManagerInterface $parserManager, ExtensionManagerInterface $extensionManager, AllowedHtmlManager $allowedHtmlManager) {
$this->configFactory = $configFactory;
$this->parserManager = $parserManager;
$this->extensionManager = $extensionManager;
$this->allowedHtmlManager = $allowedHtmlManager;
}
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults) {
$type = substr($definition['type'], 9);
$configuration = $this->configFactory
->get("markdown.{$type}.{$value}")
->get();
switch ($type) {
case 'parser':
return $value instanceof ParserInterface ? $value : $this->parserManager
->createInstance((string) $value, $configuration);
case 'extension':
return $value instanceof ExtensionInterface ? $value : $this->extensionManager
->createInstance((string) $value, $configuration);
case 'allowed_html':
return $value instanceof AllowedHtmlInterface ? $value : $this->allowedHtmlManager
->createInstance((string) $value, $configuration);
}
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
return isset($definition['type']) && strpos($definition['type'], 'markdown:') !== FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MarkdownParamConverter:: |
protected | property | The Markdown Allowed HTML Plugin Manager service. | |
MarkdownParamConverter:: |
protected | property | The Config Factory service. | |
MarkdownParamConverter:: |
protected | property | The Markdown Extension Plugin Manager service. | |
MarkdownParamConverter:: |
protected | property | The Markdown Parser Plugin Manager service. | |
MarkdownParamConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface:: |
|
MarkdownParamConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides ParamConverterInterface:: |
|
MarkdownParamConverter:: |
public | function | MarkdownParamConverter constructor. |