Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
fontweight.php
1<?php
2
4
6
8{
9 // todo: check this!
10 protected const FONT_BOLD_MATCHER = '/font-weight-bold/i';
11
15 protected $blockId;
19 protected $content;
20
21 public function __construct($blockId, $content)
22 {
23 $this->blockId = $blockId;
24 $this->content = $content;
25 }
26
27 public function update(): void
28 {
29 // todo: what about partners? !!!!!!!!!!!!!
30 $this->changeWeightClass();
31
32 $this->save();
33 }
34
35 protected function save(): void
36 {
37 BlockTable::update(
38 $this->blockId,
39 [
40 'CONTENT' => $this->content
41 ]
42 );
43 }
44
45 protected function changeWeightClass()
46 {
47 $this->content = preg_replace(self::FONT_BOLD_MATCHER, 'g-font-weight-700', $this->content);
48 }
49
50
51 public static function updateLanding(int $lid): void
52 {
53 $res = BlockTable::getList(
54 [
55 'select' => [
56 'ID', 'CONTENT'
57 ],
58 'filter' => [
59 'LID' => $lid,
60 ],
61 ]
62 );
63 while ($row = $res->fetch())
64 {
65 $block = new self($row['ID'], $row['CONTENT']);
66 $block->update();
67 }
68 }
69
70}