Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
handlermanager.php
1<?php
2
4
6{
7 protected $handlerListByPostText = array();
8 protected $handlerListByType = array();
9
10 public function __construct()
11 {
12 $this->buildHandlerList();
13 }
14
15 protected function buildHandlerList(): void
16 {
18 $shareClass = Share::className();
20 $createTaskClass = CreateTask::className();
22 $createEntityClass = CreateEntity::className();
24 $fileVersionClass = FileVersion::className();
26 $taskInfoClass = TaskInfo::className();
27
28 $this->handlerListByPostText = array(
29 $shareClass::getPostText() => $shareClass,
30 $createTaskClass::getPostText() => $createTaskClass,
31 $createEntityClass::getPostText() => $createEntityClass,
32 $fileVersionClass::getPostText() => $fileVersionClass,
33 $taskInfoClass::getPostText() => $taskInfoClass,
34 );
35 $this->handlerListByType = array(
36 $shareClass::getType() => $shareClass,
37 $createTaskClass::getType() => $createTaskClass,
38 $createEntityClass::getType() => $createEntityClass,
39 $fileVersionClass::getType() => $fileVersionClass,
40 $taskInfoClass::getType() => $taskInfoClass,
41 );
42 }
43
44 public function getHandlerByPostText($postText)
45 {
46 $handler = false;
47
48 if(isset($this->handlerListByPostText[$postText]))
49 {
50 $handler = new $this->handlerListByPostText[$postText]();
51 }
52
53 return $handler;
54 }
55
56 public function getHandlerByType($type)
57 {
58 $handler = false;
59
60 if(isset($this->handlerListByType[$type]))
61 {
62 $handler = new $this->handlerListByType[$type]();
63 }
64
65 return $handler;
66 }
67}