public function BehaviorService::addBehaviorService in Synonyms 2.0.x
Same name and namespace in other branches
- 8 src/SynonymsService/BehaviorService.php \Drupal\synonyms\SynonymsService\BehaviorService::addBehaviorService()
Add a new discovered behavior service.
Parameters
\Drupal\synonyms\BehaviorInterface\BehaviorInterface $behavior_service: Behavior service object that was discovered and should be added into the list of known ones.
string $id: Service ID that corresponds to this behavior service.
File
- src/
SynonymsService/ BehaviorService.php, line 55
Class
- BehaviorService
- Collect all known synonyms behavior services.
Namespace
Drupal\synonyms\SynonymsServiceCode
public function addBehaviorService(BehaviorInterface $behavior_service, $id) {
// It is more convenient to use machine readable IDs as array keys here.
$machine_id = $behavior_service
->getId();
// Behavior services collector.
if (!isset($this->behaviorServices[$machine_id])) {
$this->behaviorServices[$machine_id] = $behavior_service;
}
// Widget services collector.
if ($behavior_service instanceof WidgetInterface && !isset($this->widgetServices[$machine_id])) {
$this->widgetServices[$machine_id] = $behavior_service;
}
}