MediaWiki master
EventRelayerGroup.php
Go to the documentation of this file.
1<?php
8
9use UnexpectedValueException;
10
18 protected $configByChannel = [];
19
21 protected $relayers = [];
22
26 public function __construct( array $config ) {
27 $this->configByChannel = $config;
28 }
29
34 public function getRelayer( $channel ) {
35 $channelKey = isset( $this->configByChannel[$channel] )
36 ? $channel
37 : 'default';
38
39 if ( !isset( $this->relayers[$channelKey] ) ) {
40 if ( !isset( $this->configByChannel[$channelKey] ) ) {
41 throw new UnexpectedValueException( "No config for '$channelKey'" );
42 }
43
44 $config = $this->configByChannel[$channelKey];
45 $class = $config['class'];
46
47 $this->relayers[$channelKey] = new $class( $config );
48 }
49
50 return $this->relayers[$channelKey];
51 }
52}
53
55class_alias( EventRelayerGroup::class, 'EventRelayerGroup' );
Factory class for spawning EventRelayer objects using configuration.
Base class for reliable event relays.