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