Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
pagecta.php
1<?php
2
4
5final class PageCta extends AbstractConfigField
6{
7 const BUTTON_TEXT_RESERVE = 'Reserve';
8 const BUTTON_TEXT_BOOK = 'Book Now';
9 const BUTTON_TEXT_BUY = 'Buy Now';
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 static::BUTTON_TEXT_RESERVE,
16 static::BUTTON_TEXT_BUY
17 ]);
18
19 }
20 private static function checkUrl($value) : bool
21 {
22 return array_key_exists('cta_button_url',$value) &&
23 is_string($value['cta_button_url']) &&
24 preg_match(static::URL_PATTERN,$value['cta_button_url']);
25 }
26 private static function checkBelowButtonText($value)
27 {
28 return array_key_exists('below_button_text',$value) && is_string($value['below_button_text']);
29 }
30
31 protected static function checkValueFields($value): bool
32 {
33 return static::checkBelowButtonText($value) && static::checkButtonText($value) && static::checkUrl($value);
34 }
35
36 protected static function setDefaultFields($value)
37 {
38 $value['below_button_text'] = "Powered by Bitrix";
39 return $value;
40 }
41
45 static function available(): bool
46 {
47 return true;
48 }
49
53 static function required(): bool
54 {
55 return false;
56 }
57
58 protected static function getFields() : array
59 {
60 return array_merge(parent::getFields(),['cta_button_url','cta_button_text','below_button_text']);
61 }
62}