forked from jbh/c5-bootstrap-autonav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.php
43 lines (32 loc) · 1.21 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
<?php defined('C5_EXECUTE') or die(_("Access Denied."));
class C5BootstrapAutonavPackage extends Package {
protected $pkgHandle = 'c5-bootstrap-autonav';
protected $pkgName = 'C5 Bootstrap Autonav';
protected $pkgDescription = 'Adds a Bootstrap template for the core autonav block.';
protected $appVersionRequired = '5.7.5';
protected $pkgVersion = '0.1';
public function install() {
$pkg = parent::install(); //this will automatically install our package-level db.xml schema for us (among other things)
$this->installOrUpgrade($pkg);
}
public function upgrade() {
$this->installOrUpgrade($this);
parent::upgrade();
}
//Put most installation tasks here -- makes development easier
// (just make sure the actions you perform are "non-destructive",
// for example, check if a page exists before adding it).
private function installOrUpgrade($pkg) {
//Frontend Blocktype:
$this->getOrInstallBlockType($pkg, 'autonav');
}
/*** UTILITY FUNCTIONS ***/
private function getOrInstallBlockType($pkg, $btHandle) {
$bt = BlockType::getByHandle($btHandle);
if (empty($bt)) {
BlockType::installBlockTypeFromPackage($btHandle, $pkg);
$bt = BlockType::getByHandle($btHandle);
}
return $bt;
}
}