class FormatConverter in Bibliography & Citation 2.0.x
Same name and namespace in other branches
- 8 src/Routing/FormatConverter.php \Drupal\bibcite\Routing\FormatConverter
Converts export plugin id to definition array.
Hierarchy
- class \Drupal\bibcite\Routing\FormatConverter implements ParamConverterInterface
Expanded class hierarchy of FormatConverter
1 string reference to 'FormatConverter'
1 service uses FormatConverter
File
- src/
Routing/ FormatConverter.php, line 12
Namespace
Drupal\bibcite\RoutingView source
class FormatConverter implements ParamConverterInterface {
/**
* Format plugins manager service.
*
* @var \Drupal\bibcite\Plugin\BibciteFormatManagerInterface
*/
protected $formatManager;
/**
* Format converter constructor.
*
* @param \Drupal\bibcite\Plugin\BibciteFormatManagerInterface $format_manager
* Format plugins manager service.
*/
public function __construct(BibciteFormatManagerInterface $format_manager) {
$this->formatManager = $format_manager;
}
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults) {
if (!empty($value) && $this->formatManager
->hasDefinition($value)) {
return $this->formatManager
->createInstance($value);
}
return NULL;
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && $definition['type'] == 'bibcite_format';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormatConverter:: |
protected | property | Format plugins manager service. | |
FormatConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface:: |
|
FormatConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides ParamConverterInterface:: |
|
FormatConverter:: |
public | function | Format converter constructor. |