MediaWiki master
EventRelayerGroup.php
Go to the documentation of this file.
1<?php
22
23use UnexpectedValueException;
24
32 protected $configByChannel = [];
33
35 protected $relayers = [];
36
40 public function __construct( array $config ) {
41 $this->configByChannel = $config;
42 }
43
48 public function getRelayer( $channel ) {
49 $channelKey = isset( $this->configByChannel[$channel] )
50 ? $channel
51 : 'default';
52
53 if ( !isset( $this->relayers[$channelKey] ) ) {
54 if ( !isset( $this->configByChannel[$channelKey] ) ) {
55 throw new UnexpectedValueException( "No config for '$channelKey'" );
56 }
57
58 $config = $this->configByChannel[$channelKey];
59 $class = $config['class'];
60
61 $this->relayers[$channelKey] = new $class( $config );
62 }
63
64 return $this->relayers[$channelKey];
65 }
66}
67
69class_alias( EventRelayerGroup::class, 'EventRelayerGroup' );
Factory class for spawning EventRelayer objects using configuration.
Base class for reliable event relays.