blob: 7e9660d128a4675ae235fa77f7f9a7168cd7acf8 (
plain)
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
|
<?php
namespace Psecio\Gatekeeper;
use Phinx\Migration\AbstractMigration;
/**
* Custom migration extending the base Phinx version to allow
* for custom table prefix handling
*/
abstract class PhinxMigration extends AbstractMigration
{
/**
* Default table prefix (empty)
* @var string
*/
protected $prefix = '';
/**
* Initialize, set the prefix if provided
*/
public function init()
{
if (isset($_SERVER['DB_TABLE_PREFIX'])) {
$this->setPrefix($_SERVER['DB_TABLE_PREFIX']);
}
}
/**
* Set the current prefix value
*
* @param string $prefix Table prefix value
*/
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
/**
* Get the current prefix value
* If defined, returns the value plus an underscore ("_")
*
* @return string Formatted prefix or empty string
*/
public function getPrefix()
{
return (strlen($this->prefix) > 0) ? $this->prefix.'_' : '';
}
/**
* Get the current table name value
*
* @return string Name of current migration's table
*/
public function getTableName()
{
return $this->getPrefix().$this->tableName;
}
}
|