You are here

class SynonymsBehaviorServiceParamConverter in Synonyms 8

Param converter for synonyms behavior service.

Hierarchy

Expanded class hierarchy of SynonymsBehaviorServiceParamConverter

1 string reference to 'SynonymsBehaviorServiceParamConverter'
synonyms.services.yml in ./synonyms.services.yml
synonyms.services.yml
1 service uses SynonymsBehaviorServiceParamConverter
synonyms.param_converter.synonyms_behavior in ./synonyms.services.yml
Drupal\synonyms\ParamConverter\SynonymsBehaviorServiceParamConverter

File

src/ParamConverter/SynonymsBehaviorServiceParamConverter.php, line 12

Namespace

Drupal\synonyms\ParamConverter
View source
class SynonymsBehaviorServiceParamConverter implements ParamConverterInterface {

  /**
   * Synonyms Behavior Service.
   *
   * @var \Drupal\synonyms\SynonymsService\BehaviorService
   */
  protected $behaviorService;

  /**
   * SynonymsBehaviorServiceParamConverter constructor.
   */
  public function __construct(BehaviorService $behavior_service) {
    $this->behaviorService = $behavior_service;
  }

  /**
   * {@inheritdoc}
   */
  public function convert($value, $definition, $name, array $defaults) {
    return $this->behaviorService
      ->getBehaviorService($value)['service'];
  }

  /**
   * {@inheritdoc}
   */
  public function applies($definition, $name, Route $route) {
    return !empty($definition['type']) && $definition['type'] == 'synonyms_behavior_service';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SynonymsBehaviorServiceParamConverter::$behaviorService protected property Synonyms Behavior Service.
SynonymsBehaviorServiceParamConverter::applies public function Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface::applies
SynonymsBehaviorServiceParamConverter::convert public function Converts path variables to their corresponding objects. Overrides ParamConverterInterface::convert
SynonymsBehaviorServiceParamConverter::__construct public function SynonymsBehaviorServiceParamConverter constructor.