Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
baseservice.php
1<?php
2
4
10
11abstract class BaseService
12{
14 protected static $instance;
15
16 public function __clone(){}
17 public function __wakeup(){}
18
22 public static function getInstance()
23 {
24 if (empty(static::$instance))
25 {
26 static::$instance = static::createInstance(
27 static::getConfig(static::class)
28 );
29 }
30
31 return static::$instance;
32 }
33
34 protected static function createInstance(Container $config)
35 {
36 return new static($config);
37 }
38
39 protected function processException(\Exception $exception): void
40 {
41 ErrorService::getInstance()->addError(
42 new Error($exception->getMessage(), $exception->getCode())
43 );
44 }
45
46 protected function __construct(Container $config)
47 {
48 }
49
50 protected static function getConfig(string $class)
51 {
52 return Factory::createConfig($class);
53 }
54}
static getConfig(string $class)
static createInstance(Container $config)
processException(\Exception $exception)