-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.php
76 lines (64 loc) · 1.84 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
<?php
namespace Concrete\Package\Pusher;
use C5j\Pusher\ApiServiceProvider;
use Concrete\Core\Asset\AssetList;
use Concrete\Core\Foundation\Service\ProviderList;
use Concrete\Core\Package\Package;
class Controller extends Package
{
protected $pkgHandle = 'pusher';
protected $pkgVersion = '0.1.1';
protected $appVersionRequired = '8.5.4';
protected $pkgAutoloaderRegistries = [
'src' => '\C5j\Pusher',
];
/**
* {@inheritdoc}
*/
public function getPackageName()
{
return t('Pusher Channels');
}
/**
* {@inheritdoc}
*/
public function getPackageDescription()
{
return t('A concrete5 package to add Pusher Channels HTTP PHP Library and manage API key.');
}
public function install()
{
$this->registerAutoload();
if (!class_exists('\Pusher\Pusher')) {
throw new \RuntimeException(t('Required libraries not found.'));
}
$pkg = parent::install();
$this->installContentFile('config/singlepages.xml');
return $pkg;
}
public function on_start()
{
$this->registerAutoload();
$assetList = AssetList::getInstance();
if ($assetList) {
$assetList->register(
'javascript',
'pusher',
'https://js.pusher.com/7.0/pusher.min.js',
['local' => false]
);
}
/** @var ProviderList $providerList */
$providerList = $this->app->make(ProviderList::class);
$providerList->registerProvider(ApiServiceProvider::class);
}
/**
* Register autoloader.
*/
protected function registerAutoload()
{
if (file_exists($this->getPackagePath() . '/vendor/autoload.php')) {
require $this->getPackagePath() . '/vendor/autoload.php';
}
}
}