Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
pagepost.php
1<?php
2
4
5final class PagePost extends AbstractConfigField
6{
7
8 const BUTTON_TEXT_RESERVE = 'Reserve';
9 const BUTTON_TEXT_BOOK = 'Book Now';
10 const BUTTON_TEXT_BUY = 'Buy Now';
11
12 private static function checkButtonText($value) : bool
13 {
14 return array_key_exists('cta_button_text',$value) && in_array($value['cta_button_text'],[
15 static::BUTTON_TEXT_BOOK,
16 static::BUTTON_TEXT_RESERVE,
17 static::BUTTON_TEXT_BUY
18 ]);
19
20 }
21 private static function checkUrl($value) : bool
22 {
23 return array_key_exists('cta_button_url',$value) &&
24 is_string($value['cta_button_url']) &&
25 preg_match(static::URL_PATTERN,$value['cta_button_url']);
26 }
27 private static function checkTitle($value) : bool
28 {
29 return array_key_exists('title',$value) && is_string($value['title']);
30 }
31 private static function checkSubtitle($value) : bool
32 {
33 return array_key_exists('subtitle',$value) && is_string($value['subtitle']);
34 }
35
36 protected static function checkValueFields($value): bool
37 {
38 return static::checkSubtitle($value) &&
39 static::checkTitle($value) &&
40 static::checkButtonText($value) &&
41 static::checkUrl($value);
42 }
43
44 protected static function setDefaultFields($value)
45 {
46 $value['subtitle'] = "Powered by Bitrix";
47 return $value;
48 }
49
53 static function available(): bool
54 {
55 return true;
56 }
57
61 static function required(): bool
62 {
63 return false;
64 }
65
66 protected static function getFields() : array
67 {
68 return array_merge(parent::getFields(),['cta_button_url','cta_button_text','title','subtitle']);
69 }
70}
Definition pagepost.php:6
static checkValueFields($value)
Definition pagepost.php:36
const BUTTON_TEXT_BUY
Definition pagepost.php:10
static getFields()
Definition pagepost.php:66
const BUTTON_TEXT_RESERVE
Definition pagepost.php:8
const BUTTON_TEXT_BOOK
Definition pagepost.php:9
static setDefaultFields($value)
Definition pagepost.php:44
static available()
Definition pagepost.php:53
static required()
Definition pagepost.php:61