PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.4.5.2
JetFormBuilder — Dynamic Blocks Form Builder v3.4.5.2
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 2 years ago migration-exception.php 2 years ago migration-model.php 2 years ago migrator.php 2 years ago view-migrations.php 2 years ago
migrator.php
129 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 JFB_Components\Repository\Repository_Pattern_Trait;
9 use Jet_Form_Builder\Db_Queries\Execution_Builder;
10 use Jet_Form_Builder\Exceptions\Query_Builder_Exception;
11 use Jet_Form_Builder\Migrations\Profilers\Base_Migration_Profiler;
12 use Jet_Form_Builder\Migrations\Versions\Base_Migration;
13 use Jet_Form_Builder\Migrations\Versions\Version_2_1_0;
14 use Jet_Form_Builder\Migrations\Versions\Version_2_1_7;
15 use Jet_Form_Builder\Migrations\Versions\Version_2_1_8;
16
17 // If this file is called directly, abort.
18 if ( ! defined( 'WPINC' ) ) {
19 die;
20 }
21
22 /**
23 * @method static Migrator instance()
24 *
25 * Class Migrator
26 * @package Jet_Form_Builder\Migrations
27 */
28 class Migrator {
29
30 use Instance_Trait;
31 use Repository_Pattern_Trait;
32
33 private $installed_migrations = array();
34
35 public function __construct() {
36 $this->rep_install();
37 }
38
39 /**
40 * @return array
41 */
42 public function rep_instances(): array {
43 return array(
44 new Version_2_1_0(),
45 new Version_2_1_7(),
46 new Version_2_1_8(),
47 new Version_3_1_7(),
48 );
49 }
50
51 /**
52 * @param null|Base_Migration_Profiler $profiler
53 *
54 * @throws Migration_Exception
55 */
56 public function install( $profiler = null ) {
57 /** @var Base_Migration $migration */
58 foreach ( $this->rep_get_items() as $migration ) {
59 $migration->set_profiler( $profiler )->install();
60 }
61 }
62
63 /**
64 * @param null|Base_Migration_Profiler $profiler
65 *
66 * @throws Migration_Exception
67 */
68 public function uninstall( $profiler = null ) {
69 /** @var Base_Migration $migration */
70 foreach ( $this->rep_get_items() as $migration ) {
71 $migration->set_profiler( $profiler )->uninstall();
72 }
73 }
74
75 public function is_installed_all(): bool {
76 $items = $this->rep_get_items();
77
78 /** @var Base_Migration $item */
79 foreach ( $items as $item ) {
80 if ( ! $item->is_installed() ) {
81 return false;
82 }
83 }
84
85 return true;
86 }
87
88 public function is_installed( Base_Migration $migration ): bool {
89 $version = get_class( $migration );
90
91 if ( isset( $this->installed_migrations[ $version ] ) ) {
92 return $this->installed_migrations[ $version ];
93 }
94
95 $installed = true;
96
97 try {
98 View_Migrations::findOne(
99 array(
100 'version' => $version,
101 )
102 )->query()->query_one();
103 } catch ( Query_Builder_Exception $exception ) {
104 $exception->unset_log();
105 $installed = false;
106 }
107
108 $this->installed_migrations[ $version ] = $installed;
109
110 return $this->installed_migrations[ $version ];
111 }
112
113 public function set_installed( Base_Migration $migration ): Migrator {
114 $version = get_class( $migration );
115
116 $this->installed_migrations[ $version ] = true;
117
118 return $this;
119 }
120
121 public function set_uninstalled( Base_Migration $migration ): Migrator {
122 $version = get_class( $migration );
123
124 $this->installed_migrations[ $version ] = false;
125
126 return $this;
127 }
128 }
129