FormatConverter.php in Bibliography & Citation 2.0.x
File
src/Routing/FormatConverter.php
View source
<?php
namespace Drupal\bibcite\Routing;
use Drupal\bibcite\Plugin\BibciteFormatManagerInterface;
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Symfony\Component\Routing\Route;
class FormatConverter implements ParamConverterInterface {
protected $formatManager;
public function __construct(BibciteFormatManagerInterface $format_manager) {
$this->formatManager = $format_manager;
}
public function convert($value, $definition, $name, array $defaults) {
if (!empty($value) && $this->formatManager
->hasDefinition($value)) {
return $this->formatManager
->createInstance($value);
}
return NULL;
}
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && $definition['type'] == 'bibcite_format';
}
}