403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/im/lib/V2/Anchor/DI/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/im/lib/V2/Anchor/DI/AnchorContainer.php
<?php

declare(strict_types=1);

namespace Bitrix\Im\V2\Anchor\DI;

use Bitrix\Im\V2\Anchor\AnchorProvider;
use Bitrix\Im\V2\Anchor\AnchorService;
use Bitrix\Im\V2\Anchor\Push\PushService;
use Bitrix\Im\V2\Anchor\ReadService;
use Bitrix\Im\V2\Message;
use Bitrix\Main\DI\ServiceLocator;
use Bitrix\Main\NotImplementedException;

final class AnchorContainer
{
	private static ?self $instance = null;

	public static function getInstance(): self
	{
		if (self::$instance === null)
		{
			self::$instance = new self();
		}

		return self::$instance;
	}

	public function getAnchorService(Message $message): AnchorService
	{
		return $this->get(
			static fn (): AnchorService => new AnchorService($message),
			'im.anchor.service.' . $message->getId()
		);
	}

	public function getReadService(): ReadService
	{
		return $this->get(ReadService::class, 'im.anchor.read.service');
	}

	public function getAnchorProvider(): AnchorProvider
	{
		return $this->get(AnchorProvider::class, 'im.anchor.provider');
	}

	public function getPushService(): PushService
	{
		return $this->get(PushService::class, 'im.anchor.push.service');
	}

	private function get(string|callable $constructor, string $id, array $args = []): object
	{
		$locator = ServiceLocator::getInstance();

		if (!$locator->has($id))
		{
			$config = [
				'constructorParams' => $args,
				is_callable($constructor) ? 'constructor' : 'className' => $constructor,
			];

			$locator->addInstanceLazy($id, $config);
		}

		return $locator->get($id);
	}


	private function __construct()
	{
	}

	/**
	 * @throws NotImplementedException
	 */
	public function __clone()
	{
		throw new NotImplementedException();
	}

	/**
	 * @throws NotImplementedException
	 */
	public function __serialize(): array
	{
		throw new NotImplementedException();
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit