Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
pagecard.php
1<?php
2
4
5final class PageCard extends AbstractConfigField
6{
7
8 const BUTTON_TEXT_BOOK = 'Book';
9 const SEE_ALL_TEXT = 'see_all_text';
10
11 private static function checkButtonText($value) : bool
12 {
13 return array_key_exists('cta_button_text',$value) && in_array($value['cta_button_text'],[
14 static::BUTTON_TEXT_BOOK,
15 ]);
16 }
17 private static function checkSeeAllText($value) : bool
18 {
19 return array_key_exists('see_all_text',$value) && in_array($value['see_all_text'],[
20 static::SEE_ALL_TEXT
21 ]);
22
23 }
24 private static function checkUrl($value) : bool
25 {
26 return array_key_exists('see_all_url',$value) &&
27 is_string($value['see_all_url']) &&
28 preg_match(static::URL_PATTERN,$value['see_all_url']);
29 }
30
31 protected static function checkValueFields($value): bool
32 {
33 return static::checkButtonText($value) && static::checkSeeAllText($value) && static::checkUrl($value);
34 }
35
36 protected static function setDefaultFields($value)
37 {
38 $value['see_all_text'] = static::SEE_ALL_TEXT;
39 $value['cta_button_text'] = static::BUTTON_TEXT_BOOK;
40 return $value;
41 }
42
46 static function available(): bool
47 {
48 return true;
49 }
50
54 static function required(): bool
55 {
56 return false;
57 }
58
59 protected static function getFields() : array
60 {
61 return array_merge(parent::getFields(),['cta_button_text','see_all_text','see_all_url']);
62 }
63}