afterdeletecoupon.php
1 month ago
afterdeletecustomer.php
1 month ago
afterdeleteemployee.php
1 month ago
afterdeletepackorder.php
1 month ago
afterdeletereservation.php
1 month ago
afterdeleteservice.php
1 month ago
aftersavecoupon.php
1 month ago
aftersavecustomer.php
1 month ago
aftersaveemployee.php
1 month ago
aftersavepackorder.php
1 month ago
aftersavereservation.php
1 month ago
aftersaveservice.php
1 month ago
index.html
1 month ago
statuschangepackageorder.php
1 month ago
statuschangereservation.php
1 month ago
afterdeletecustomer.php
99 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 | /** |
| 15 | * Web hook handler for customers deletion. |
| 16 | * |
| 17 | * @since 1.7 |
| 18 | */ |
| 19 | class VAPWebHookAfterDeleteCustomer extends VAPWebHook |
| 20 | { |
| 21 | /** |
| 22 | * @override |
| 23 | * Class constructor. |
| 24 | * |
| 25 | * @param string $hook The hook name. |
| 26 | * @param mixed $payload The payload to deliver. |
| 27 | */ |
| 28 | public function __construct($hook, $payload) |
| 29 | { |
| 30 | if (is_array($payload)) |
| 31 | { |
| 32 | // The payload is an array containing the list of all the deleted |
| 33 | // customers and a JTable instance. We need to use only the first |
| 34 | // argument of the list. |
| 35 | $payload = array_shift($payload); |
| 36 | } |
| 37 | |
| 38 | // construct through parent |
| 39 | parent::__construct('onAfterDeleteCustomer', $payload); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @override |
| 44 | * Returns a readable name of the hook. |
| 45 | * |
| 46 | * @return string |
| 47 | */ |
| 48 | public function getName() |
| 49 | { |
| 50 | return JText::translate('VAP_WEBHOOK_DELETE_CUSTOMER'); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @override |
| 55 | * Returns the registered payload. |
| 56 | * |
| 57 | * @param mixed $options Either an array or an object, which should contain |
| 58 | * the value of the specified parameters. |
| 59 | * |
| 60 | * @return mixed |
| 61 | */ |
| 62 | public function getPayload($options = array()) |
| 63 | { |
| 64 | // avoid duplicates |
| 65 | $ids = array_values(array_unique($this->payload)); |
| 66 | |
| 67 | if (count($ids) > 1) |
| 68 | { |
| 69 | // load list of IDs |
| 70 | $payload = array('id' => $ids); |
| 71 | } |
| 72 | else |
| 73 | { |
| 74 | // take only the first element |
| 75 | $payload = array('id' => array_shift($ids)); |
| 76 | } |
| 77 | |
| 78 | return $payload; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @override |
| 83 | * Comparator to check whether 2 instances share the same payload parent. |
| 84 | * |
| 85 | * @return boolean |
| 86 | */ |
| 87 | public function equalsTo($webhook) |
| 88 | { |
| 89 | if (!$webhook instanceof VAPWebHookAfterDeleteCustomer) |
| 90 | { |
| 91 | // invalid instance |
| 92 | return false; |
| 93 | } |
| 94 | |
| 95 | // always use a single instance containing all the deleted records |
| 96 | return true; |
| 97 | } |
| 98 | } |
| 99 |