PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.10.2
Fluent Support – Helpdesk & Customer Support Ticket System v1.10.2
2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 68 releases
fluent-support / app / Services / Tickets / Importer / MigratorService.php

MigratorService.php in Fluent Support – Helpdesk & Customer Support Ticket System 1.10.2, at app/Services/Tickets/Importer/MigratorService.php

79 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Services\Tickets\Importer;
4
5 class MigratorService
6 {
7 /**
8 * This `getStats` method will fetch available other systems data
9 */
10 public function getStats()
11 {
12 $stats = [];
13
14 if (defined('WPAS_VERSION')) {
15 $stats[] = $this->mapClassWithHandler('awesome-support')->stats();
16 }
17
18 if (defined('WPSC_VERSION')) {
19 $stats[] = $this->mapClassWithHandler('support-candy')->stats();
20 }
21
22 if (defined('JSST_PLUGIN_PATH')) {
23 $stats[] = $this->mapClassWithHandler('js-helpdesk')->stats();
24 }
25
26 $stats[] = $this->mapClassWithHandler('helpscout')->stats();
27 $stats[] = $this->mapClassWithHandler('freshdesk')->stats();
28 $stats[] = $this->mapClassWithHandler('zendesk')->stats();
29
30 return [
31 'stats' => $stats
32 ];
33 }
34
35 /**
36 * This `handleImport` method will handle the ticket import
37 * @param int $page // It can be page number or ticket id for inserting ticket
38 * @param string $handler
39 */
40 public function handleImport($page, $handler, $query=[])
41 {
42 if($query){
43 $class = $this->mapClassWithHandler($handler);
44 $class->setAccessToken($query['access_token']);
45 isset($query['mailbox']) ? $class->setMailboxId($query['mailbox']) : '';
46 isset($query['domain']) ? $class->setDomain($query['domain']) : '';
47 isset($query['email']) ? $class->setEmail($query['email']) : '';
48
49 return $class->doMigration($page, $handler);
50 }
51
52 return $this->mapClassWithHandler($handler)->doMigration($page, $handler);
53 }
54
55 public function deleteTickets($page, $handler)
56 {
57 return $this->mapClassWithHandler($handler)->deleteTickets($page);
58 }
59
60 // This method is a helper method of `handleImport` method it's responsible for calling a class by $handler
61 private function mapClassWithHandler($handler)
62 {
63 $namespace = "FluentSupport\App\Services\Tickets\Importer\\";
64
65 $classMapper = apply_filters('fluent_support/migrator_class_mapper', [
66 'awesome-support' => 'AwesomeSupportTickets',
67 'support-candy' => 'SupportCandyTickets',
68 'js-helpdesk' => 'JSHelpdeskTickets',
69 'helpscout' => 'HelpScoutTickets',
70 'freshdesk' => 'FreshDeskTickets',
71 'zendesk' => 'ZendeskTickets'
72 ]);
73
74 $class = $namespace . $classMapper[$handler];
75
76 return new $class();
77 }
78 }
79