Code: Select all
public function init(): void
{
parent::init();
// Render the template for my plugin.
Event::on(
View::class,
View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS,
function(RegisterTemplateRootsEvent $event) {
$event->roots['_jsonify'] = __DIR__ . '/src/templates';
}
);
// Register the event that should be triggered on this url.
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_CP_URL_RULES,
function(RegisterUrlRulesEvent $event) {
$event->rules['_jsonify/import/test'] = '_jsonify/import/test';
}
);
Craft::$app->onInit(function() {
$this->getJsonFile();
$this->decodeJsonFile();
});
}
Code: Select all