PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.1.20
Responsive Menu – Create Mobile-Friendly Menu v3.1.20
4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 All 90 releases
responsive-menu / app / Database / Migration.php

Migration.php in Responsive Menu – Create Mobile-Friendly Menu 3.1.20, at app/Database/Migration.php

54 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ResponsiveMenu\Database;
4 use ResponsiveMenu\Management\OptionManager;
5
6 class Migration {
7
8 private $manager;
9 private $old_version;
10 private $new_version;
11 private $defaults;
12
13 public function __construct(OptionManager $manager, $old_version, $new_version, $defaults) {
14 $this->manager = $manager;
15 $this->old_version = $old_version;
16 $this->new_version = $new_version;
17 $this->defaults = $defaults;
18 }
19
20 public function needsTable() {
21 return substr($this->old_version, 0, 1) < 3;
22 }
23
24 public function needsUpdate() {
25 return version_compare($this->old_version, $this->new_version, '<');
26 }
27
28 public function addNewOptions() {
29 return $this->manager->createOptions(array_diff_key($this->defaults, $this->manager->all()->toArray()));
30 }
31
32 public function tidyUpOptions() {
33 return $this->manager->removeOptions(array_diff_key($this->manager->all()->toArray(), $this->defaults));
34 }
35
36 public function getMigrationClasses() {
37 $migrations = [];
38 if($this->old_version):
39 foreach(glob(__DIR__ . '/Migrations/Migrate_*.php') as $file) {
40 $class_name = 'ResponsiveMenu\Database\Migrations\\' . basename($file, '.php');
41 $class = new $class_name;
42 if(
43 version_compare($class->getOldVersion(), $this->new_version, '<') &&
44 version_compare($this->old_version, $class->getNewVersion(), '<')
45 )
46 $migrations[$class->getOldVersion()] = $class;
47 }
48
49 uksort($migrations, 'version_compare');
50 endif;
51 return $migrations;
52 }
53
54 }