Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
parsermanager.php
1<?php
2
3
5
6
8{
12 private $data;
16 private $timezones;
20 private $events = [];
24 private $components = [];
28 private $method = '';
29
30 public static function getInstance(string $data): ParserManager
31 {
32 return new self($data);
33 }
34
35 public function __construct(string $data = '')
36 {
37 $this->data = $data;
38 }
39
40 public function parseData(): ParserManager
41 {
42 try
43 {
44 $parser = Parser::getInstance($this->data);
45 $this->components = $parser->handleData()->getComponents();
46 }
47 catch(\Exception $e)
48 {
49 }
50
51 return $this;
52 }
53
55 {
56 $components = $this->components;
57
58 foreach ($components as $component)
59 {
60 if ($component instanceof Calendar)
61 {
62 $this->events = $component->handleEvents()->getEvents();
63 $this->method = $component->getMethod();
64 }
65 elseif ($component instanceof Event)
66 {
67 $this->events[] = $component->getContent();
68 }
69 }
70
71 return $this;
72 }
73
74 public function getComponents(): array
75 {
76 return $this->components;
77 }
78
79 public function getEvents()
80 {
81 return $this->events;
82 }
83
84 public function getProcessedEvents()
85 {
86 return $this->parseData()
87 ->handleComponents()
88 ->getEvents();
89 }
90
91 public function getMethod()
92 {
93 return $this->method;
94 }
95}