Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
bufferarea.php
1<?
3
5
6class BufferArea extends StaticArea
7{
8 private $staticPart = null;
9 private $dynamicPart = null;
10 private $started = false;
11 private $ended = false;
12
17 public function __construct($id, $autoContainer = true)
18 {
19 parent::__construct($id);
20 if (!$autoContainer)
21 {
22 $this->setContainerId($id);
23 }
24 }
25
37 public function begin($stub = null)
38 {
39 if ($this->started)
40 {
41 throw new NotSupportedException("begin() has been called. Frame id: ".$this->getId().".");
42 }
43
44 $this->startDynamicArea();
45
46 $this->started = true;
47 $this->staticPart = $stub;
48 ob_start();
49 return $this;
50 }
51
63 public function beginStub()
64 {
65 if (!$this->started)
66 {
67 throw new NotSupportedException("begin() has not been called. Frame id: ".$this->getId().".");
68 }
69
70 $this->dynamicPart = ob_get_contents();
71 ob_end_clean();
72 ob_start();
73 return $this;
74 }
75
87 public function end()
88 {
89 if (!$this->started)
90 {
91 throw new NotSupportedException("begin() has not been called. Frame id: ".$this->getId().".");
92 }
93
94 if ($this->ended)
95 {
96 throw new NotSupportedException("begin() has been called. Frame id: ".$this->getId().".");
97 }
98
99 //if beginStub() was called
100 if ($this->dynamicPart !== null)
101 {
102 if ($this->staticPart !== null)
103 {
104 throw new NotSupportedException("begin() was called with a stub. Frame id: ".$this->getId().".");
105 }
106
107 $this->staticPart = ob_get_contents();
108 ob_end_clean();
109 echo $this->dynamicPart;
110 }
111 else
112 {
113 $this->dynamicPart = ob_get_contents();
114 if ($this->staticPart === null)
115 {
116 $this->staticPart = $this->dynamicPart;
117 }
118 ob_end_flush();
119 }
120
121 $this->setStub($this->staticPart);
122 $this->finishDynamicArea();
123
124 $this->ended = true;
125 return $this;
126 }
127
133 public function isStarted()
134 {
135 return $this->started;
136 }
137
143 public function isEnded()
144 {
145 return $this->ended;
146 }
147}
148
149class_alias("Bitrix\\Main\\Composite\\BufferArea", "Bitrix\\Main\\Page\\FrameBuffered");
150class_alias("Bitrix\\Main\\Composite\\BufferArea", "Bitrix\\Main\\Page\\FrameHelper");
__construct($id, $autoContainer=true)