-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.php
96 lines (75 loc) · 2.53 KB
/
controller.php
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
88
89
90
91
92
93
94
95
96
<?php namespace Concrete\Package\Seven;
defined('C5_EXECUTE') or die('Access Denied.');
use Concrete\Core\Database\Connection\Connection;
use Concrete\Core\Entity\Package as PackageEntity;
use Concrete\Core\Package\Package;
use Concrete\Core\Page\Single as SinglePage;
use Exception;
use Seven\Concrete5\Options;
use Seven\Concrete5\Routes;
final class Controller extends Package {
/** @var string $MIN_PHP_VERSION */
private $MIN_PHP_VERSION = '5.6.0';
/** @var string $appVersionRequired */
protected $appVersionRequired = '8.5.2';
/** @var string[] $pkgAutoloaderRegistries */
protected $pkgAutoloaderRegistries = [
'src' => '\Seven\Concrete5',
];
/** @var string $pkgHandle */
protected $pkgHandle = 'seven';
/** @var string $pkgVersion */
protected $pkgVersion = '2.3.1';
/** @return string */
public function getPackageDescription() {
return t('Send SMS/TTS-Calls/RCS via seven.');
}
/** @return string */
public function getPackageName() {
return t('seven');
}
/**
* @param PackageEntity $pkg
* @throws Exception
*/
private function commonTasks(PackageEntity $pkg) {
if (version_compare(PHP_VERSION, $this->MIN_PHP_VERSION, '<')) {
throw new Exception(sprintf('PHP %s or greater needed to use this package.',
$this->MIN_PHP_VERSION));
}
$this->installContentFile('install.xml');
$this->getConfig();
foreach (Options::all() as $group => $arr) {
foreach ($arr as $k => $default) {
$key = $group . '.' . $k;
if ($this->config->has($key)) {
continue;
}
$this->config->save($key, (string)(is_bool($default) ? (int)$default : $default));
}
}
foreach (Routes::all() as $route) {
SinglePage::add($route, $pkg);
}
}
/** @throws Exception */
public function install() {
$this->commonTasks(parent::install());
}
/** @throws Exception */
public function upgrade() {
parent::upgrade();
$this->commonTasks($this->getPackageEntity());
}
/**
*
*/
public function uninstall() {
parent::uninstall();
/** @var Connection $db */
$db = $this->app->make('database/connection');
$db->createQueryBuilder()->delete('Config')
->where('configNamespace = :namespace')
->setParameters([':namespace' => $this->pkgHandle])->execute();
}
}