PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5.2
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5.2
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 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.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / migrations / migrator.php
jetformbuilder / includes / migrations Last commit date
profilers 2 years ago versions 4 days ago auto-migrator.php 4 days ago migration-exception.php 2 years ago migration-model.php 2 years ago migrator.php 4 days ago view-migrations.php 2 years ago
migrator.php
133 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Migrations;
5
6 use Jet_Form_Builder\Classes\Instance_Trait;
7 use Jet_Form_Builder\Migrations\Versions\Version_3_1_7;
8 use Jet_Form_Builder\Migrations\Versions\Version_3_6_1;
9 use JFB_Components\Repository\Repository_Pattern_Trait;
10 use Jet_Form_Builder\Db_Queries\Execution_Builder;
11 use Jet_Form_Builder\Exceptions\Query_Builder_Exception;
12 use Jet_Form_Builder\Migrations\Profilers\Base_Migration_Profiler;
13 use Jet_Form_Builder\Migrations\Versions\Base_Migration;
14 use Jet_Form_Builder\Migrations\Versions\Version_2_1_0;
15 use Jet_Form_Builder\Migrations\Versions\Version_2_1_7;
16 use Jet_Form_Builder\Migrations\Versions\Version_2_1_8;
17 use Jet_Form_Builder\Migrations\Versions\Version_3_6_5_2;
18
19 // If this file is called directly, abort.
20 if ( ! defined( 'WPINC' ) ) {
21 die;
22 }
23
24 /**
25 * @method static Migrator instance()
26 *
27 * Class Migrator
28 * @package Jet_Form_Builder\Migrations
29 */
30 class Migrator {
31
32 use Instance_Trait;
33 use Repository_Pattern_Trait;
34
35 private $installed_migrations = array();
36
37 public function __construct() {
38 $this->rep_install();
39 }
40
41 /**
42 * @return array
43 */
44 public function rep_instances(): array {
45 return array(
46 new Version_2_1_0(),
47 new Version_2_1_7(),
48 new Version_2_1_8(),
49 new Version_3_1_7(),
50 new Version_3_6_1(),
51 new Version_3_6_5_2(),
52 );
53 }
54
55 /**
56 * @param null|Base_Migration_Profiler $profiler
57 *
58 * @throws Migration_Exception
59 */
60 public function install( $profiler = null ) {
61 /** @var Base_Migration $migration */
62 foreach ( $this->rep_get_items() as $migration ) {
63 $migration->set_profiler( $profiler )->install();
64 }
65 }
66
67 /**
68 * @param null|Base_Migration_Profiler $profiler
69 *
70 * @throws Migration_Exception
71 */
72 public function uninstall( $profiler = null ) {
73 /** @var Base_Migration $migration */
74 foreach ( $this->rep_get_items() as $migration ) {
75 $migration->set_profiler( $profiler )->uninstall();
76 }
77 }
78
79 public function is_installed_all(): bool {
80 $items = $this->rep_get_items();
81
82 /** @var Base_Migration $item */
83 foreach ( $items as $item ) {
84 if ( ! $item->is_installed() ) {
85 return false;
86 }
87 }
88
89 return true;
90 }
91
92 public function is_installed( Base_Migration $migration ): bool {
93 $version = get_class( $migration );
94
95 if ( isset( $this->installed_migrations[ $version ] ) ) {
96 return $this->installed_migrations[ $version ];
97 }
98
99 $installed = true;
100
101 try {
102 View_Migrations::findOne(
103 array(
104 'version' => $version,
105 )
106 )->query()->query_one();
107 } catch ( Query_Builder_Exception $exception ) {
108 $exception->unset_log();
109 $installed = false;
110 }
111
112 $this->installed_migrations[ $version ] = $installed;
113
114 return $this->installed_migrations[ $version ];
115 }
116
117 public function set_installed( Base_Migration $migration ): Migrator {
118 $version = get_class( $migration );
119
120 $this->installed_migrations[ $version ] = true;
121
122 return $this;
123 }
124
125 public function set_uninstalled( Base_Migration $migration ): Migrator {
126 $version = get_class( $migration );
127
128 $this->installed_migrations[ $version ] = false;
129
130 return $this;
131 }
132 }
133