Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Initiator.php
1<?php
2
4
6{
7 public function getDefaultFrom(): ?string
8 {
9 $fromList = $this->getFromList();
10 $from = isset($fromList[0]) ? $fromList[0]['id'] : null;
11 //Try to find alphanumeric from
12 foreach ($fromList as $item)
13 {
14 if (!preg_match('#^[0-9]+$#', $item['id']))
15 {
16 $from = $item['id'];
17 break;
18 }
19 }
20 return $from;
21 }
22
23 public function getFirstFromList()
24 {
25 $fromList = $this->getFromList();
26 if (!is_array($fromList))
27 {
28 return null;
29 }
30
31 foreach ($fromList as $item)
32 {
33 if (isset($item['id']) && $item['id'])
34 {
35 return $item['id'];
36 }
37 }
38
39 return null;
40 }
41
42 public function isCorrectFrom($from): bool
43 {
44 $fromList = $this->getFromList();
45 foreach ($fromList as $item)
46 {
47 if ($from === $item['id'])
48 {
49 return true;
50 }
51 }
52 return false;
53 }
54}