1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Saito - The Threaded Web Forum |
7
|
|
|
* |
8
|
|
|
* @copyright Copyright (c) the Saito Project Developers 2018 |
9
|
|
|
* @link https://github.com/Schlaefer/Saito |
10
|
|
|
* @license http://opensource.org/licenses/MIT |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Installer\Controller; |
14
|
|
|
|
15
|
|
|
use App\Model\Table\SettingsTable; |
16
|
|
|
use Cake\Cache\Cache; |
17
|
|
|
use Cake\Controller\Controller; |
18
|
|
|
use Cake\Core\Configure; |
19
|
|
|
use Cake\Datasource\ConnectionManager; |
20
|
|
|
use Cake\I18n\I18n; |
21
|
|
|
use Cake\Log\LogTrait; |
22
|
|
|
use Cake\ORM\Table; |
23
|
|
|
use Migrations\Migrations; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Installer App Controller |
27
|
|
|
* |
28
|
|
|
* @property SettingsTable $Settings |
29
|
|
|
*/ |
30
|
|
|
class AppController extends Controller |
31
|
|
|
{ |
32
|
|
|
use LogTrait; |
33
|
|
|
|
34
|
|
|
/** @var Migrations */ |
35
|
|
|
protected $migrations; |
36
|
|
|
|
37
|
|
|
public $helpers = [ |
38
|
|
|
'Breadcrumbs' => ['className' => 'BootstrapUI.Breadcrumbs'], |
39
|
|
|
'Flash' => ['className' => 'BootstrapUI.Flash'], |
40
|
|
|
'Form' => ['className' => 'BootstrapUI.Form'], |
41
|
|
|
'Html' => ['className' => 'BootstrapUI.Html'], |
42
|
|
|
'Paginator' => ['className' => 'BootstrapUI.Paginator'], |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritDoc} |
47
|
|
|
*/ |
48
|
|
|
public function initialize() |
49
|
|
|
{ |
50
|
|
|
Cache::clear(); |
51
|
|
|
Cache::disable(); |
52
|
|
|
|
53
|
|
|
parent::initialize(); |
54
|
|
|
|
55
|
|
|
$this->loadModel('Settings'); |
56
|
|
|
$this->migrations = $this->initializeMigrations($this->Settings); |
57
|
|
|
|
58
|
|
|
$locale = Configure::read('Saito.language'); |
59
|
|
|
I18n::setLocale($locale); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Initialize migration property |
64
|
|
|
* |
65
|
|
|
* @param Table $table a table to read the config from |
66
|
|
|
* @return Migrations |
67
|
|
|
*/ |
68
|
|
|
private function initializeMigrations(Table $table) |
69
|
|
|
{ |
70
|
|
|
$installerConfigName = 'installer'; |
71
|
|
|
// if: static configuration only allowed once, but done multiple times in test-cases |
72
|
|
|
if (ConnectionManager::getConfig($installerConfigName) === null) { |
73
|
|
|
$defaultConfigName = $table->getConnection()->configName(); |
74
|
|
|
$connectionConfig = ConnectionManager::getConfig($defaultConfigName); |
75
|
|
|
$connectionConfig['quoteIdentifiers'] = true; |
76
|
|
|
ConnectionManager::setConfig($installerConfigName, $connectionConfig); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return new Migrations(['connection' => $installerConfigName]); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|