-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.php
67 lines (55 loc) · 1.85 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
<?php
namespace Concrete\Package\MdFormResponderNotification;
use Concrete\Core\Express\Controller\Manager;
use Concrete\Core\Package\Package;
use Concrete\Core\Page\Page;
use Concrete\Core\Page\Single;
use Macareux\Package\FormResponderNotification\Express\Controller\AutoResponseController;
class Controller extends Package
{
protected $pkgHandle = 'md_form_responder_notification';
protected $appVersionRequired = '8.5.5';
protected $pkgVersion = '0.1.0';
protected $pkgAutoloaderRegistries = [
'src' => '\Macareux\Package\FormResponderNotification',
];
public function getPackageName()
{
return t('Macareux Form Responder Notification');
}
public function getPackageDescription()
{
return t('Send responders a copy of their response.');
}
public function on_start()
{
$forms = (array) $this->getFileConfig()->get('forms');
if ($forms) {
/** @var Manager $manager */
$manager = $this->app->make(Manager::class);
foreach ($forms as $handle => $form) {
$manager->extend($handle, function ($app) {
return new AutoResponseController($app);
});
}
}
}
public function install()
{
$pkg = parent::install(); // TODO: Change the autogenerated stub
$this->installSinglePages($pkg);
return $pkg;
}
public function upgrade()
{
$this->installSinglePages($this->getPackageEntity());
parent::upgrade();
}
private function installSinglePages(\Concrete\Core\Entity\Package $pkg)
{
$singlePage = Page::getByPath('/dashboard/system/mail/form_response');
if (!$singlePage || $singlePage->isError()) {
$singlePage = Single::add('/dashboard/system/mail/form_response', $pkg);
}
}
}