I've been following the screencasts for theme development and I'm at the point where I need to register some assets for a block in order for that block to work as it uses a plugin. After registering the assets in my block's controller however, I get the following error:
<?php
namespace Application\Block\Blockname;
defined("C5_EXECUTE") or die("Access Denied.");
use Concrete\Core\Block\BlockController;
use Concrete\Core\Asset\AssetList;
use Concrete\Core\Asset\Asset;
use Core;
use Loader;
class Controller extends BlockController
{
public $helpers = array (
0 => 'form',
);
public $btFieldsRequired = array (
0 => 'name',
1 => 'svgData',
2 => 'width',
3 => 'colour',
4 => 'time',
);
protected $btExportFileColumns = array (
);
protected $btTable = 'btBlockname';
protected $btInterfaceWidth = 400;
protected $btInterfaceHeight = 500;
protected $btIgnorePageThemeGridFrameworkContainer = false;
protected $btCacheBlockRecord = true;
protected $btCacheBlockOutput = true;
protected $btCacheBlockOutputOnPost = true;
protected $btCacheBlockOutputForRegisteredUsers = true;
protected $btCacheBlockOutputLifetime = 0;
protected $pkg = false;
public function getBlockTypeDescription()
{
return t("Block description");
}
public function getBlockTypeName()
{
return t("Block name");
}
public function getSearchableContent()
{
$content = array();
$content[] = $this->name;
$content[] = $this->svgData;
$content[] = $this->width;
$content[] = $this->time;
return implode(" ", $content);
}
public function add()
{
$this->requireAsset('core/colorpicker');
$this->set('btFieldsRequired', $this->btFieldsRequired);
}
public function edit()
{
$db = \Database::get();
$this->requireAsset('core/colorpicker');
$this->set('btFieldsRequired', $this->btFieldsRequired);
}
public function save($args)
{
$db = \Database::get();
$args['svgData'] = htmlentities($args['svgData']);
$args['width'] = str_replace(',', '.', $args['width']);
$args['time'] = str_replace(',', '.', $args['time']);
parent::save($args);
}
public function validate($args)
{
$e = Core::make("helper/validation/error");
if (in_array("name", $this->btFieldsRequired) && (trim($args["name"]) == "")) {
$e->add(t("The %s field is required.", t("Name")));
}
if(in_array("svgData",$this->btFieldsRequired) && trim($args["svgData"]) == ""){
$e->add(t("The %s field is required.", t("SVG Data")));
}
if (trim($args['width']) != "") {
$args['width'] = str_replace(',', '.', $args['width']);
if ($args['width'] < 0) {
$e->add(t("The %s field needs a minimum of %s.", t("Stroke width"), 0));
}
elseif ($args['width'] > 5) {
$e->add(t("The %s field needs a maximum of %s.", t("Stroke width"), 5));
}
} elseif (in_array("width", $this->btFieldsRequired)) {
$e->add(t("The %s field is required.", t("Stroke width")));
}
if (in_array("colour", $this->btFieldsRequired) && (trim($args["colour"]) == "")) {
$e->add(t("The %s field is required.", t("Stroke colour")));
}
if (trim($args['time']) != "") {
$args['time'] = str_replace(',', '.', $args['time']);
if ($args['time'] < 0) {
$e->add(t("The %s field needs a minimum of %s.", t("Timing"), 0));
}
elseif ($args['time'] > 10) {
$e->add(t("The %s field needs a maximum of %s.", t("Timing"), 10));
}
} elseif (in_array("time", $this->btFieldsRequired)) {
$e->add(t("The %s field is required.", t("Timing")));
}
return $e;
}
public function composer()
{
if (file_exists('application/blocks/blockname/auto.js')) {
$al = \Concrete\Core\Asset\AssetList::getInstance();
$al->register('javascript', 'auto-js-blockname', 'blocks/blockname/auto.js', array(), $this->pkg);
$this->requireAsset('javascript', 'auto-js-blockname');
}
$this->edit();
}
public function on_start()
{
$al = Asset::getInstance();
$al->register(
'javascript', 'inview', 'application/themes/themename/assets/inview/jquery.inview.min.js',
array('version' => '1.1.2', 'minify' => false, 'combine' => true)
);
$al->registerGroup('inview', array(
array('javascript', 'jquery'),
array('javascript', 'inview')
));
}
public function registerViewAssets()
{
$this->requireAsset('inview');
}
}