mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-08-10 01:35:13 +00:00
reintroduce init method
Some plugins (structpublish) overwrite it in their own class.
This commit is contained in:
@ -16,6 +16,22 @@ class helper_plugin_struct_db extends DokuWiki_Plugin
|
|||||||
/** @var SQLiteDB */
|
/** @var SQLiteDB */
|
||||||
protected $sqlite;
|
protected $sqlite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the database
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected function init()
|
||||||
|
{
|
||||||
|
$this->sqlite = new SQLiteDB('struct', DOKU_PLUGIN . 'struct/db/');
|
||||||
|
|
||||||
|
// register our JSON function with variable parameters
|
||||||
|
$this->sqlite->getPdo()->sqliteCreateFunction('STRUCT_JSON', [$this, 'STRUCT_JSON'], -1);
|
||||||
|
|
||||||
|
// this function is meant to be overwritten by plugins
|
||||||
|
$this->sqlite->getPdo()->sqliteCreateFunction('IS_PUBLISHER', [$this, 'IS_PUBLISHER'], -1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $throw throw an Exception when sqlite not available
|
* @param bool $throw throw an Exception when sqlite not available
|
||||||
* @return SQLiteDB|null
|
* @return SQLiteDB|null
|
||||||
@ -24,19 +40,13 @@ class helper_plugin_struct_db extends DokuWiki_Plugin
|
|||||||
{
|
{
|
||||||
if ($this->sqlite === null) {
|
if ($this->sqlite === null) {
|
||||||
try {
|
try {
|
||||||
$this->sqlite = new SQLiteDB('struct', DOKU_PLUGIN . 'struct/db/');
|
$this->init();
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
if (defined('DOKU_UNITTEST')) throw new \RuntimeException('Could not load SQLite', 0, $exception);
|
if (defined('DOKU_UNITTEST')) throw new \RuntimeException('Could not load SQLite', 0, $exception);
|
||||||
ErrorHandler::logException($exception);
|
ErrorHandler::logException($exception);
|
||||||
if ($throw) throw new StructException('no sqlite');
|
if ($throw) throw new StructException('no sqlite');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// register our JSON function with variable parameters
|
|
||||||
$this->sqlite->getPdo()->sqliteCreateFunction('STRUCT_JSON', [$this, 'STRUCT_JSON'], -1);
|
|
||||||
|
|
||||||
// this function is meant to be overwritten by plugins
|
|
||||||
$this->sqlite->getPdo()->sqliteCreateFunction('IS_PUBLISHER', [$this, 'IS_PUBLISHER'], -1);
|
|
||||||
}
|
}
|
||||||
return $this->sqlite;
|
return $this->sqlite;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user