MediaWiki  1.34.0
EventRelayerGroup.php
Go to the documentation of this file.
1 <?php
28  protected $configByChannel = [];
29 
31  protected $relayers = [];
32 
36  public function __construct( array $config ) {
37  $this->configByChannel = $config;
38  }
39 
44  public function getRelayer( $channel ) {
45  $channelKey = isset( $this->configByChannel[$channel] )
46  ? $channel
47  : 'default';
48 
49  if ( !isset( $this->relayers[$channelKey] ) ) {
50  if ( !isset( $this->configByChannel[$channelKey] ) ) {
51  throw new UnexpectedValueException( "No config for '$channelKey'" );
52  }
53 
54  $config = $this->configByChannel[$channelKey];
55  $class = $config['class'];
56 
57  $this->relayers[$channelKey] = new $class( $config );
58  }
59 
60  return $this->relayers[$channelKey];
61  }
62 }
EventRelayerGroup
Factory class for spawning EventRelayer objects using configuration.
Definition: EventRelayerGroup.php:26
EventRelayerGroup\$configByChannel
array[] $configByChannel
Definition: EventRelayerGroup.php:28
EventRelayerGroup\$relayers
EventRelayer[] $relayers
Definition: EventRelayerGroup.php:31
EventRelayerGroup\__construct
__construct(array $config)
Definition: EventRelayerGroup.php:36
EventRelayerGroup\getRelayer
getRelayer( $channel)
Definition: EventRelayerGroup.php:44
EventRelayer
Base class for reliable event relays.
Definition: EventRelayer.php:27