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