General Kirby,
here’s my problem:
In the root of a plugin I’m writing, say myplugin.php
, I’m going like this:
<?php
// myplugin.php
// Composer autoload
require_once __DIR__ . DS . 'vendor' . DS . 'autoload.php';
// Loading my library
require_once __DIR__ . DS . 'lib' . DS . 'lib.php';
function init() {
return new Kirby\Plugins\MyPlugin\MyClass;
}
Alright, but there’s a problem: In this file plugin/lib/lib.php
, I’m calling a hook on panel.file.upload
, eg creating PDF from certain documents. So I’m like
<?php
// lib/lib.php
namespace Kirby\Plugins\MyPlugin;
use C;
use PDFLib;
// ...
kirby()->hook('panel.file.upload', 'createPDF');
class MyClass {
private $someValue;
public function __construct() {
$this->someValue = c::get('plugin.myplugin', 'some-default');
}
// ...
public function createPDF($file) {
try {
// Checking file type since only images are processed
if ($file->type() == 'document') {
// do stuff
}
} catch (Exception $e) {
return response::error($e->getMessage());
}
}
}
Now, whenever I upload stuff, I get this error: Function createPDF() does not exist
- what can I possibly do to debug this?