Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
content.php
1<?php
9
13
14Loc::loadMessages(__FILE__);
15
20abstract class Content
21{
22 const TYPE_JSON = 'json';
23 const TYPE_HTML = 'html';
24
26 protected $errors;
27
29 protected $response;
30
31 public static function create (Response $response, $type)
32 {
33 switch ($type)
34 {
36 return new ContentHtml($response);
37
39 default:
40 return new ContentJson($response);
41 }
42 }
43
49 {
50 $this->errors = new ErrorCollection;
51 $this->response = $response;
52 }
53
57 public function onFlush()
58 {
59
60 }
61
65 abstract public function toText();
66
71 public function addError($message, $code = null)
72 {
73 $this->errors->setError(new Error($message, $code));
74 }
78 public function addPermissionError($message = null)
79 {
80 if (!$message)
81 {
82 $message = 'Access denied.';
83 }
84
85 $this->errors->setError(new Error($message, 0));
86 }
87
91 public function getErrorCollection()
92 {
93 return $this->errors;
94 }
95
96 protected function getErrorMessages()
97 {
98 $list = array();
99 foreach ($this->errors as $error)
100 {
102 $list[] = $error->getMessage();
103 }
104 return $list;
105 }
106}
static loadMessages($file)
Definition loc.php:64
static create(Response $response, $type)
Definition content.php:31