1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
<?php
namespace TotalPoll\Migrations\Polls\Templates; ! defined( 'ABSPATH' ) && exit();
use TotalPoll\Contracts\Migrations\Poll\Template\Poll as PollContract; use TotalPollVendors\TotalCore\Helpers\Arrays;
/** * Poll Migration Template. * @package TotalPoll\Migrations\Polls\Templates */ class Poll extends Template implements PollContract { /** * Poll's data. * * @var array $data */ protected $data = [];
/** * Poll constructor. */ public function __construct() { $this->data = TotalPoll( 'polls.defaults' ) ?: []; }
/** * Set poll title. * * @param $title */ public function setTitle( $title ) { $this->data['title'] = $title; }
/** * Get poll title. * * @return string */ public function getTitle() { return $this->data['title'] ?: ''; }
/** * Add question to poll. * * @param $question */ public function addQuestion( $question ) { $this->data['questions'] = Arrays::setDotNotation( $this->data['questions'], count( $this->data['questions'] ), $question ); }
/** * Add custom field to poll. * * @param $field */ public function addField( $field ) { $this->data['fields'] = Arrays::setDotNotation( $this->data['fields'], count( $this->data['fields'] ), $field ); }
/** * Add settings section to poll. * * @param $section * @param $value */ public function addSettings( $section, $value ) { $this->data = Arrays::setDotNotation( $this->data, $section, $value ); } }
|