Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
textpropertytype.php
1<?php
2
3
5
6
8{
9 private $text;
10 private $disableEscaping;
11
12 public static function getInstance($names, string $text, $disableEscaping = false): TextPropertyType
13 {
14 return new self($names, $text, $disableEscaping);
15 }
16
17 public function __construct($names, string $text, $disableEscaping = false)
18 {
19 parent::__construct($names);
20
21 $this->text = $text;
22 $this->disableEscaping = $disableEscaping;
23 }
24
25 public function getValue(): string
26 {
27 if ($this->disableEscaping) {
28 return $this->text;
29 }
30
31 $replacements = [
32 '\\' => '\\\\',
33 '"' => '\\"',
34 ',' => '\\,',
35 ';' => '\\;',
36 "\n" => '\\n',
37 ];
38
39 return str_replace(array_keys($replacements), $replacements, $this->text);
40 }
41
42 public function getOriginalValue(): string
43 {
44 return $this->text;
45 }
46}
__construct($names, string $text, $disableEscaping=false)
static getInstance($names, string $text, $disableEscaping=false)