Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
fixfontweight.php
1<?php
2
4
7
8final class FixFontWeight extends Stepper
9{
10 protected const FONT_PARAMS = ':wght@300;400;500;600;700;900';
11 protected const FONT_NEW_PARAMS = ':wght@100;200;300;400;500;600;700;800;900';
12 protected const STEP_PORTION = 10;
13 protected const CONTINUE_EXECUTING = true;
14 protected const STOP_EXECUTING = false;
15
21 public function execute(array &$result): bool
22 {
23 $res = HookDataTable::getList(
24 [
25 'select' => [
26 'ID', 'VALUE'
27 ],
28 'filter' => [
29 'HOOK' => 'FONTS',
30 ],
31 ]
32 );
33
34 if (!$result['checkedRows'])
35 {
36 $result['checkedRows'] = 0;
37 }
38
39 $countFixedRows = 0;
40 $countRows = 0;
41 while ($row = $res->fetch())
42 {
43 if ($countRows > $result['checkedRows'])
44 {
45 $result['checkedRows']++;
46 $search = self::FONT_PARAMS;
47 $replace = self::FONT_NEW_PARAMS;
48 $value = str_replace($search, $replace, $row['VALUE']);
49 HookDataTable::update(
50 $row['ID'],
51 ['VALUE' => $value]
52 );
53 $countFixedRows++;
54 if ($countFixedRows === self::STEP_PORTION)
55 {
56 $result['checkedRows'] = $countRows;
58 }
59 }
60 $countRows++;
61 }
62
64 }
65}