mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-07 19:24:28 +02:00
create event for dbview_definition hook
This commit is contained in:
parent
9e3b0b3c40
commit
9cf0ce0b99
6 changed files with 15 additions and 4 deletions
|
@ -71,6 +71,7 @@ final class HookEventBridge
|
|||
ArrayFilterEvent::STORAGE_CONFIG => 'storage_config',
|
||||
ArrayFilterEvent::STORAGE_INSTANCE => 'storage_instance',
|
||||
ArrayFilterEvent::DB_STRUCTURE_DEFINITION => 'dbstructure_definition',
|
||||
ArrayFilterEvent::DB_VIEW_DEFINITION => 'dbview_definition',
|
||||
HtmlFilterEvent::HEAD => 'head',
|
||||
HtmlFilterEvent::FOOTER => 'footer',
|
||||
HtmlFilterEvent::PAGE_HEADER => 'page_header',
|
||||
|
@ -122,6 +123,7 @@ final class HookEventBridge
|
|||
ArrayFilterEvent::STORAGE_CONFIG => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::STORAGE_INSTANCE => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::DB_STRUCTURE_DEFINITION => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::DB_VIEW_DEFINITION => 'onArrayFilterEvent',
|
||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Database\Definition;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
use Friendica\Event\ArrayFilterEvent;
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
namespace Friendica\Database\Definition;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
use Friendica\Event\ArrayFilterEvent;
|
||||
|
||||
/**
|
||||
* Stores the whole View definitions
|
||||
|
@ -62,12 +63,16 @@ class ViewDefinition
|
|||
{
|
||||
$definition = require $this->configFile;
|
||||
|
||||
if (!$definition) {
|
||||
if (!is_array($definition)) {
|
||||
throw new Exception('Corrupted database structure config file static/dbstructure.config.php');
|
||||
}
|
||||
|
||||
if ($withAddonStructure) {
|
||||
Hook::callAll('dbview_definition', $definition);
|
||||
$eventDispatcher = DI::eventDispatcher();
|
||||
|
||||
$definition = $eventDispatcher->dispatch(
|
||||
new ArrayFilterEvent(ArrayFilterEvent::DB_VIEW_DEFINITION, $definition),
|
||||
)->getArray();
|
||||
}
|
||||
|
||||
$this->definition = $definition;
|
||||
|
|
|
@ -80,6 +80,8 @@ final class ArrayFilterEvent extends Event
|
|||
|
||||
public const DB_STRUCTURE_DEFINITION = 'friendica.data.db_structure_definition';
|
||||
|
||||
public const DB_VIEW_DEFINITION = 'friendica.data.db_view_definition';
|
||||
|
||||
private array $array;
|
||||
|
||||
public function __construct(string $name, array $array)
|
||||
|
|
|
@ -60,6 +60,7 @@ class HookEventBridgeTest extends TestCase
|
|||
ArrayFilterEvent::STORAGE_CONFIG => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::STORAGE_INSTANCE => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::DB_STRUCTURE_DEFINITION => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::DB_VIEW_DEFINITION => 'onArrayFilterEvent',
|
||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
||||
|
@ -296,6 +297,7 @@ class HookEventBridgeTest extends TestCase
|
|||
[ArrayFilterEvent::STORAGE_CONFIG, 'storage_config'],
|
||||
[ArrayFilterEvent::STORAGE_INSTANCE, 'storage_instance'],
|
||||
[ArrayFilterEvent::DB_STRUCTURE_DEFINITION, 'dbstructure_definition'],
|
||||
[ArrayFilterEvent::DB_VIEW_DEFINITION, 'dbview_definition'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ class ArrayFilterEventTest extends TestCase
|
|||
[ArrayFilterEvent::STORAGE_CONFIG, 'friendica.data.storage_config'],
|
||||
[ArrayFilterEvent::STORAGE_INSTANCE, 'friendica.data.storage_instance'],
|
||||
[ArrayFilterEvent::DB_STRUCTURE_DEFINITION, 'friendica.data.db_structure_definition'],
|
||||
[ArrayFilterEvent::DB_VIEW_DEFINITION, 'friendica.data.db_view_definition'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue