PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.7.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.7.3
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
templately / includes / Core / Importer / Form.php

Form.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! 3.7.3, at includes/Core/Importer/Form.php

57 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Templately\Core\Importer;
4
5 use Exception;
6 use FluentForm\App\Services\Transfer\TransferService;
7 use FluentForm\Framework\Request\File;
8
9 class Form {
10 protected $plugin;
11 protected $file;
12 protected $settings = [];
13
14 public function __construct( $plugin, $file, $settings = [] ) {
15 $this->plugin = $plugin;
16 $this->file = $file;
17 $this->settings = $settings;
18 }
19
20 /**
21 * @throws Exception
22 */
23 public function run() {
24 if ( ! file_exists( $this->file ) ) {
25 throw new Exception( __( 'Form JSON does not exists.', 'templately' ) );
26 }
27
28 $data = $this->import();
29
30 if ( ! $data ) {
31 throw new Exception( __( 'Cannot be imported.', 'templately' ) );
32 }
33
34 return $data;
35 }
36
37 public function import() {
38 try {
39 $results = null;
40 switch ( $this->plugin ) {
41 case 'fluent-forms' && is_plugin_active( 'fluentform/fluentform.php' ) && class_exists( File::class ) && class_exists( TransferService::class ):
42 $fileObject = new File( $this->file, '' );
43 $importer = new TransferService();
44 $inserted = $importer->importForms( $fileObject );
45 $results = key( $inserted['inserted_forms'] );
46 break;
47 default:
48 break;
49 }
50
51 return $results;
52
53 } catch ( Exception $e ) {
54 return null;
55 }
56 }
57 }