class BehaviorService in Synonyms 2.0.x
Same name and namespace in other branches
- 8 src/SynonymsService/BehaviorService.php \Drupal\synonyms\SynonymsService\BehaviorService
Collect all known synonyms behavior services.
Collect all known synonyms behavior services during dependency injection container compilation.
Hierarchy
- class \Drupal\synonyms\SynonymsService\BehaviorService implements ContainerInjectionInterface
Expanded class hierarchy of BehaviorService
4 files declare their use of BehaviorService
- BehaviorForm.php in src/
Form/ BehaviorForm.php - SettingsForm.php in src/
Form/ SettingsForm.php - SynonymConfigController.php in src/
Controller/ SynonymConfigController.php - SynonymsEntity.php in modules/
synonyms_views_filter/ src/ Plugin/ views/ filter/ SynonymsEntity.php
1 string reference to 'BehaviorService'
1 service uses BehaviorService
File
- src/
SynonymsService/ BehaviorService.php, line 16
Namespace
Drupal\synonyms\SynonymsServiceView source
class BehaviorService implements ContainerInjectionInterface {
/**
* Collected behavior services.
*
* @var array
*/
protected $behaviorServices;
/**
* Collected widget services.
*
* @var array
*/
protected $widgetServices;
/**
* BehaviorService constructor.
*/
public function __construct() {
$this->behaviorServices = [];
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static();
}
/**
* Add a new discovered behavior service.
*
* @param \Drupal\synonyms\BehaviorInterface\BehaviorInterface $behavior_service
* Behavior service object that was discovered and should be added into the
* list of known ones.
* @param string $id
* Service ID that corresponds to this behavior service.
*/
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;
}
}
/**
* Array of known behavior services.
*
* @return array
* The return value
*/
public function getBehaviorServices() {
return $this->behaviorServices;
}
/**
* Array of known widget services.
*
* @return array
* The return value
*/
public function getWidgetServices() {
return $this->widgetServices;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BehaviorService:: |
protected | property | Collected behavior services. | |
BehaviorService:: |
protected | property | Collected widget services. | |
BehaviorService:: |
public | function | Add a new discovered behavior service. | |
BehaviorService:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
BehaviorService:: |
public | function | Array of known behavior services. | |
BehaviorService:: |
public | function | Array of known widget services. | |
BehaviorService:: |
public | function | BehaviorService constructor. |