mediawiki-extensions-Echo/includes/EchoServices.php
Jeena Huneidi 596729d852 Make AttributeManager a service
Adds AttributeManager to EchoServices so that dependencies of
AttributeManager can be injected.

Bug: T275148
Change-Id: I4fa5084d72914d16b6d218e7dd3521f5a1919b80
2021-02-26 12:58:23 -08:00

46 lines
1.2 KiB
PHP

<?php
use EchoPush\NotificationServiceClient;
use EchoPush\SubscriptionManager;
use MediaWiki\MediaWikiServices;
class EchoServices {
/** @var MediaWikiServices */
private $services;
/** @return EchoServices */
public static function getInstance(): EchoServices {
return new self( MediaWikiServices::getInstance() );
}
/**
* @param MediaWikiServices $services
* @return EchoServices
*/
public static function wrap( MediaWikiServices $services ): EchoServices {
return new self( $services );
}
/** @param MediaWikiServices $services */
public function __construct( MediaWikiServices $services ) {
$this->services = $services;
}
/** @return NotificationServiceClient */
public function getPushNotificationServiceClient(): NotificationServiceClient {
return $this->services->getService( 'EchoPushNotificationServiceClient' );
}
/** @return SubscriptionManager */
public function getPushSubscriptionManager(): SubscriptionManager {
return $this->services->getService( 'EchoPushSubscriptionManager' );
}
/** @return EchoAttributeManager */
public function getAttributeManager(): EchoAttributeManager {
return $this->services->getService( 'EchoAttributeManager' );
}
}