PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.20
VikAppointments Services Booking Calendar v1.2.20
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / helpers / libraries / backup / export / rule.php
vikappointments / site / helpers / libraries / backup / export Last commit date
rule 1 month ago type 1 month ago archive.php 1 month ago director.php 1 month ago rule.php 1 month ago type.php 1 month ago
rule.php
94 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 VAPLoader::import('libraries.backup.export.archive');
15
16 /**
17 * Backup export rule abstraction.
18 *
19 * @since 1.7.1
20 */
21 abstract class VAPBackupExportRule implements JsonSerializable
22 {
23 /**
24 * The instance used to manage the archive.
25 *
26 * @var VAPBackupExportArchive
27 */
28 protected $archive;
29
30 /**
31 * Class constructor.
32 * Children classes cannot overwrite this method.
33 * @see setup()
34 *
35 * @param VAPBackupExportArchive $archive The archive manager.
36 * @param mixed $data The rule setup data.
37 */
38 final public function __construct(VAPBackupExportArchive $archive, $data = null)
39 {
40 // save a reference to the archive
41 $this->archive = $archive;
42 // set up the rule data
43 $this->setup($data);
44 }
45
46 /**
47 * Returns the rule identifier.
48 *
49 * @return string
50 */
51 public function getRule()
52 {
53 // remove the class prefix
54 $rule = preg_replace("/^VAPBackupExportRule/", '', get_class($this));
55 // place an underscore between each camelCase
56 return strtolower(preg_replace("/([a-z])([A-Z])/", '$1_$2', $rule));
57 }
58
59 /**
60 * Returns the rules instructions.
61 *
62 * @return mixed
63 */
64 abstract public function getData();
65
66 /**
67 * Configures the rule to work according to the specified data.
68 *
69 * @param mixed $data The rule setup data.
70 *
71 * @return void
72 */
73 abstract protected function setup($data);
74
75 /**
76 * Creates a standard object, containing all the supported properties,
77 * to be used when this class is passed to "json_encode()".
78 *
79 * @return object
80 *
81 * @see JsonSerializable
82 */
83 #[ReturnTypeWillChange]
84 public function jsonSerialize()
85 {
86 $rule = new stdClass;
87 $rule->role = $this->getRule();
88 $rule->data = $this->getData();
89 $rule->dateCreated = JFactory::getDate()->toSql();
90
91 return $rule;
92 }
93 }
94