54 foreach ( $lockManagerConfigs as $config ) {
56 if ( !isset( $config[
'name'] ) ) {
57 throw new Exception(
"Cannot register a lock manager with no name." );
59 $name = $config[
'name'];
60 if ( !isset( $config[
'class'] ) ) {
61 throw new Exception(
"Cannot register lock manager `{$name}` with no class." );
63 $class = $config[
'class'];
64 unset( $config[
'class'] );
65 $this->managers[$name] = [
80 return MediaWikiServices::getInstance()->getLockManagerGroupFactory()
81 ->getLockManagerGroup(
$domain );
90 MediaWikiServices::getInstance()->resetServiceForTesting(
'LockManagerGroupFactory' );
100 public function get( $name ) {
101 if ( !isset( $this->managers[$name] ) ) {
102 throw new Exception(
"No lock manager defined with the name `$name`." );
105 if ( !isset( $this->managers[$name][
'instance'] ) ) {
106 $class = $this->managers[$name][
'class'];
107 '@phan-var string $class';
108 $config = $this->managers[$name][
'config'];
109 $config[
'logger'] = LoggerFactory::getInstance(
'LockManager' );
111 $this->managers[$name][
'instance'] =
new $class( $config );
114 return $this->managers[$name][
'instance'];
125 if ( !isset( $this->managers[$name] ) ) {
126 throw new Exception(
"No lock manager defined with the name `$name`." );
128 $class = $this->managers[$name][
'class'];
130 return [
'class' => $class ] + $this->managers[$name][
'config'];
142 return isset( $this->managers[
'default'] )
143 ? $this->
get(
'default' )
158 return isset( $this->managers[
'default'] )
159 ? $this->
get(
'default' )
160 : $this->
get(
'fsLockManager' );