-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetup.php
More file actions
87 lines (67 loc) · 1.84 KB
/
Copy pathSetup.php
File metadata and controls
87 lines (67 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace DC\ThreadIcon;
use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerInstallTrait;
use XF\AddOn\StepRunnerUninstallTrait;
use XF\AddOn\StepRunnerUpgradeTrait;
use XF\Db\Schema\Alter;
use XF\Db\Schema\Create;
class Setup extends AbstractSetup
{
use StepRunnerInstallTrait;
use StepRunnerUpgradeTrait;
use StepRunnerUninstallTrait;
// ################################ INSTALLATION ####################
public function installStep1()
{
$sm = $this->schemaManager();
foreach ($this->getTables() AS $tableName => $closure)
{
$sm->createTable($tableName, $closure);
}
}
public function installStep2()
{
$sm = $this->schemaManager();
foreach ($this->getAlterTables() AS $tableName => $closure)
{
$sm->alterTable($tableName, $closure[0]);
}
}
// ################################ UNINSTALL #########################
public function uninstallStep1()
{
$sm = $this->schemaManager();
foreach (array_keys($this->getTables()) AS $tableName)
{
$sm->dropTable($tableName);
}
}
public function uninstallStep2()
{
$sm = $this->schemaManager();
foreach ($this->getAlterTables() AS $tableName => $closure)
{
$sm->alterTable($tableName, $closure[1]);
}
}
// ############################# TABLE / DATA DEFINITIONS ##############################
protected function getTables()
{
$tables = [];
$tables['xf_dcThreadIcon_icon'] = function(Create $table)
{
$table->checkExists(true);
$table->addColumn('thread_id', 'int', 10);
$table->addColumn('icon', 'varchar', 100);
$table->addColumn('position', 'enum')->values(['before', 'after'])->setDefault('before');
$table->addPrimaryKey('thread_id');
};
return $tables;
}
protected function getAlterTables()
{
$tables = [];
return $tables;
}
}