-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.php
83 lines (71 loc) · 1.77 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
<?php
/**
* Class Controller.
*
* @author: Biplob Hossain <[email protected]>
*
* @license MIT
*/
namespace Concrete\Package\JobExceptionNotifier;
use Concrete\Core\Backup\ContentImporter;
use Concrete\Core\Package\Package;
use JobExceptionNotifier\Events\JobEvents;
class Controller extends Package
{
/**
* Package handle.
*/
protected $pkgHandle = 'job_exception_notifier';
/**
* Required concrete5 version.
*/
protected $appVersionRequired = '8.1.0';
/**
* Package version.
*/
protected $pkgVersion = '0.0.1';
protected $pkgAutoloaderRegistries = [
'src/Concrete' => '\JobExceptionNotifier',
];
public function getPackageName()
{
return t('Job Exception Notifier');
}
public function getPackageDescription()
{
return t('Job Exception Notifier');
}
public function on_start(): void
{
$this->registerEvents();
}
/**
* Package install process.
*/
public function install()
{
parent::install();
$this->installXml();
}
/**
* Package upgrade process.
*/
public function upgrade()
{
parent::upgrade();
$this->installXml();
}
private function installXml()
{
$ci = new ContentImporter();
$ci->importContentFile($this->getPackagePath() . '/config/install.xml');
}
protected function registerEvents(): void
{
$config = $this->app->make('config');
if ($config->get('job_exception_notifier::settings.enabled') && $config->get('job_exception_notifier::settings.address')) {
$director = $this->app->make('director');
$director->addListener('on_job_execute', [JobEvents::class, 'onJobExecute']);
}
}
}