MediaWiki REL1_30
EventRelayerGroup.php
Go to the documentation of this file.
1<?php
22
30 protected $configByChannel = [];
31
33 protected $relayers = [];
34
38 public function __construct( array $config ) {
39 $this->configByChannel = $config;
40 }
41
46 public static function singleton() {
47 return MediaWikiServices::getInstance()->getEventRelayerGroup();
48 }
49
54 public function getRelayer( $channel ) {
55 $channelKey = isset( $this->configByChannel[$channel] )
56 ? $channel
57 : 'default';
58
59 if ( !isset( $this->relayers[$channelKey] ) ) {
60 if ( !isset( $this->configByChannel[$channelKey] ) ) {
61 throw new UnexpectedValueException( "No config for '$channelKey'" );
62 }
63
64 $config = $this->configByChannel[$channelKey];
65 $class = $config['class'];
66
67 $this->relayers[$channelKey] = new $class( $config );
68 }
69
70 return $this->relayers[$channelKey];
71 }
72}
Factory class for spawning EventRelayer objects using configuration.
__construct(array $config)
EventRelayer[] $relayers
Base class for reliable event relays.
MediaWikiServices is the service locator for the application scope of MediaWiki.