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/rest/lib/url/ |
Upload File : |
<?php namespace Bitrix\Rest\Url; use \Bitrix\Main\Web\Uri; class Base { protected $directory = ''; protected $pages = []; protected static $instance; final public static function getInstance() { if (!isset(static::$instance)) { static::$instance = new static(); } return static::$instance; } protected function getDir() { return SITE_DIR.$this->directory; } protected function getReplaced(string $url, $replace = null, $subject = null) { if (!is_null($replace) && !is_null($subject)) { $url = str_replace($replace, $subject, $url); } return $url; } protected function addParams($url, $params) { if (is_array($params)) { $uri = new Uri($url); $uri->addParams($params); $url = $uri->getUri(); } return $url; } protected function getUrl($page, $replace = null, $subject = null, $query = null) { $url = null; if(array_key_exists($page, $this->pages)) { $url = $this->getDir().$this->pages[$page]; if (!is_null($replace) && !is_null($subject)) { $url = $this->getReplaced($url, $replace, $subject); } $url = $this->getReplaced($url, '//', '/'); if(is_array($query)) { $url = $this->addParams($url, $query); } } return $url; } }