Skip to content

Instantly share code, notes, and snippets.

@hissy hissy/controller.php
Created Jul 16, 2014

Embed
What would you like to do?
#concrete5 How to load required models by the package controller
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class ExamplePackage extends Package {
protected $pkgHandle = 'example';
protected $appVersionRequired = '5.6.3';
protected $pkgVersion = '1.0';
public function getPackageDescription() {
return t('This is an example package.');
}
public function getPackageName() {
return t('Example Package');
}
public function on_start() {
// autoload
ExamplePackage::autoLoad();
}
public function install() {
// autoload
ExamplePackage::autoLoad();
// do basic install process
$pkg = parent::install();
// import contents and settings
$ci = new ContentImporter();
$ci->importContentFile($pkg->getPackagePath() . '/install.xml');
}
protected static function autoLoad() {
// Load required classes
Loader::model('example_model','example');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.