SynonymsBehaviorServiceParamConverter.php in Synonyms 8
File
src/ParamConverter/SynonymsBehaviorServiceParamConverter.php
View source
<?php
namespace Drupal\synonyms\ParamConverter;
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Drupal\synonyms\SynonymsService\BehaviorService;
use Symfony\Component\Routing\Route;
class SynonymsBehaviorServiceParamConverter implements ParamConverterInterface {
protected $behaviorService;
public function __construct(BehaviorService $behavior_service) {
$this->behaviorService = $behavior_service;
}
public function convert($value, $definition, $name, array $defaults) {
return $this->behaviorService
->getBehaviorService($value)['service'];
}
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && $definition['type'] == 'synonyms_behavior_service';
}
}