ticket-assigned.php
2 months ago
ticket-created.php
2 months ago
ticket-deleted.php
2 months ago
ticket-replied.php
2 months ago
ticket-status-changed.php
2 months ago
ticket-replied.php
108 lines
| 1 | <?php |
| 2 | /** |
| 3 | * TicketRepliedSupportGenix. |
| 4 | * php version 5.6 |
| 5 | * |
| 6 | * @category TicketRepliedSupportGenix |
| 7 | * @package SureTriggers |
| 8 | * @author BSF <username@example.com> |
| 9 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 |
| 10 | * @link https://www.brainstormforce.com/ |
| 11 | * @since 1.0.0 |
| 12 | */ |
| 13 | |
| 14 | namespace SureTriggers\Integrations\SupportGenix\Triggers; |
| 15 | |
| 16 | use SureTriggers\Controllers\AutomationController; |
| 17 | use SureTriggers\Integrations\SupportGenix\SupportGenix; |
| 18 | use SureTriggers\Traits\SingletonLoader; |
| 19 | |
| 20 | if ( ! class_exists( 'TicketRepliedSupportGenix' ) ) : |
| 21 | |
| 22 | /** |
| 23 | * TicketRepliedSupportGenix |
| 24 | * |
| 25 | * @psalm-suppress UndefinedTrait |
| 26 | */ |
| 27 | class TicketRepliedSupportGenix { |
| 28 | |
| 29 | /** |
| 30 | * Integration type. |
| 31 | * |
| 32 | * @var string |
| 33 | */ |
| 34 | public $integration = 'SupportGenix'; |
| 35 | |
| 36 | /** |
| 37 | * Trigger name. |
| 38 | * |
| 39 | * @var string |
| 40 | */ |
| 41 | public $trigger = 'ticket_replied_support_genix'; |
| 42 | |
| 43 | use SingletonLoader; |
| 44 | |
| 45 | /** |
| 46 | * Constructor |
| 47 | * |
| 48 | * @since 1.0.0 |
| 49 | */ |
| 50 | public function __construct() { |
| 51 | add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Register trigger. |
| 56 | * |
| 57 | * @param array $triggers trigger data. |
| 58 | * @return array |
| 59 | */ |
| 60 | public function register( $triggers ) { |
| 61 | $triggers[ $this->integration ][ $this->trigger ] = [ |
| 62 | 'label' => __( 'Ticket Replied', 'suretriggers' ), |
| 63 | 'action' => 'ticket_replied_support_genix', |
| 64 | 'common_action' => 'apbd-wps/action/ticket-replied', |
| 65 | 'function' => [ $this, 'trigger_listener' ], |
| 66 | 'priority' => 10, |
| 67 | 'accepted_args' => 2, |
| 68 | ]; |
| 69 | |
| 70 | return $triggers; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Trigger listener. |
| 75 | * |
| 76 | * @param object $reply reply object. |
| 77 | * @param object $ticket ticket object. |
| 78 | * |
| 79 | * @return void |
| 80 | */ |
| 81 | public function trigger_listener( $reply, $ticket ) { |
| 82 | if ( empty( $reply ) || empty( $ticket ) ) { |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | $context = [ |
| 87 | 'reply' => SupportGenix::prepare_reply_context( $reply ), |
| 88 | 'ticket' => SupportGenix::prepare_ticket_context( $ticket ), |
| 89 | ]; |
| 90 | |
| 91 | AutomationController::sure_trigger_handle_trigger( |
| 92 | [ |
| 93 | 'trigger' => $this->trigger, |
| 94 | 'context' => $context, |
| 95 | ] |
| 96 | ); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Ignore false positive |
| 102 | * |
| 103 | * @psalm-suppress UndefinedMethod |
| 104 | */ |
| 105 | TicketRepliedSupportGenix::get_instance(); |
| 106 | |
| 107 | endif; |
| 108 |