removes blocks with module's onEventMergeConfig
This commit is contained in:
parent
a080748677
commit
00b5ea76ff
73
Module.php
73
Module.php
|
@ -6,6 +6,8 @@ use Omeka\Module\AbstractModule;
|
||||||
use Laminas\EventManager\Event;
|
use Laminas\EventManager\Event;
|
||||||
use Laminas\View\Renderer\PhpRenderer;
|
use Laminas\View\Renderer\PhpRenderer;
|
||||||
use Laminas\EventManager\SharedEventManagerInterface;
|
use Laminas\EventManager\SharedEventManagerInterface;
|
||||||
|
use Laminas\ModuleManager\ModuleManager;
|
||||||
|
use Laminas\ModuleManager\ModuleEvent;
|
||||||
use Laminas\Mvc\MvcEvent;
|
use Laminas\Mvc\MvcEvent;
|
||||||
use Laminas\Mvc\Controller\AbstractController;
|
use Laminas\Mvc\Controller\AbstractController;
|
||||||
use Omeka\Mvc\Controller\Plugin\Messenger;
|
use Omeka\Mvc\Controller\Plugin\Messenger;
|
||||||
|
@ -27,29 +29,60 @@ class Module extends AbstractModule
|
||||||
'exhibit' => 'Exhibitions',
|
'exhibit' => 'Exhibitions',
|
||||||
];
|
];
|
||||||
|
|
||||||
/*
|
public function init(ModuleManager $moduleManager): void
|
||||||
public function attachListeners(SharedEventManagerInterface $sharedEventManager): void
|
|
||||||
{
|
{
|
||||||
$sharedEventManager->attach(
|
$moduleManager->getEventManager()->attach(ModuleEvent::EVENT_MERGE_CONFIG,
|
||||||
\Omeka\Api\Adapter\ItemAdapter::class,
|
[$this, 'onEventMergeConfig']);
|
||||||
'api.create.post',
|
}
|
||||||
[$this, 'afterSaveItem'],
|
|
||||||
100
|
public function onEventMergeConfig(ModuleEvent $event): void
|
||||||
);
|
{
|
||||||
$sharedEventManager->attach(
|
// Check if the main site is skipped, else the standard urls apply.
|
||||||
\Omeka\Api\Adapter\ItemAdapter::class,
|
#if (!SLUG_MAIN_SITE) {
|
||||||
'api.update.post',
|
# return;
|
||||||
[$this, 'afterSaveItem'],
|
#}
|
||||||
100
|
|
||||||
);
|
/** @var \Laminas\ModuleManager\Listener\ConfigListener $configListener */
|
||||||
$sharedEventManager->attach(
|
$configListener = $event->getParam('configListener');
|
||||||
\Omeka\Api\Adapter\ItemAdapter::class,
|
// At this point, the config is read only, so it is copied and replaced.
|
||||||
'api.delete.post',
|
$config = $configListener->getMergedConfig(false);
|
||||||
[$this, 'afterDeleteItem'],
|
|
||||||
100
|
/*
|
||||||
);
|
if (isset($config['view_helpers']['invokables']['Omeka\Form\Element\HtmlTextarea'])) {
|
||||||
|
unset($config['view_helpers']['invokables']['Omeka\Form\Element\HtmlTextarea']);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
|
if (isset($config['block_layouts']['factories']['html'])) {
|
||||||
|
unset($config['block_layouts']['factories']['html']);
|
||||||
|
}
|
||||||
|
if (isset($config['block_layouts']['sorted_names']['html'])) {
|
||||||
|
unset($config['block_layouts']['sorted_names']['html']);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (isset($config['block_layouts']['invokables']['tableOfContents'])) {
|
||||||
|
unset($config['block_layouts']['invokables']['tableOfContents']);
|
||||||
|
}
|
||||||
|
if (isset($config['block_layouts']['invokables']['browsePreview'])) {
|
||||||
|
unset($config['block_layouts']['invokables']['browsePreview']);
|
||||||
|
}
|
||||||
|
// Manage the routes for the main site when "s/site-slug/" is skipped.
|
||||||
|
// So copy routes from "site", without starting "/".
|
||||||
|
/*
|
||||||
|
foreach ($config['router']['routes']['site']['child_routes'] as $routeName => $options) {
|
||||||
|
// Skip some routes for pages that are set directly in the config.
|
||||||
|
if (isset($config['router']['routes']['top']['child_routes'][$routeName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$config['router']['routes']['top']['child_routes'][$routeName] = $options;
|
||||||
|
$config['router']['routes']['top']['child_routes'][$routeName]['options']['route'] =
|
||||||
|
ltrim($config['router']['routes']['top']['child_routes'][$routeName]['options']['route'], '/');
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$configListener->setMergedConfig($config);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getConfig()
|
public function getConfig()
|
||||||
{
|
{
|
||||||
return include __DIR__ . '/config/module.config.php';
|
return include __DIR__ . '/config/module.config.php';
|
||||||
|
|
Loading…
Reference in New Issue