Repository navigation
Expand file tree
/
Copy pathModule.php
More file actions
43 lines (40 loc) · 1.63 KB
/
Copy pathModule.php
File metadata and controls
43 lines (40 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace VocabularyLibrary;
use Laminas\EventManager\Event;
use Laminas\EventManager\SharedEventManagerInterface;
use Omeka\Module\AbstractModule;
use Omeka\Mvc\Controller\Plugin\Messenger;
use Omeka\Stdlib\Message;
class Module extends AbstractModule
{
public function getConfig()
{
return include sprintf('%s/config/module.config.php', __DIR__);
}
public function attachListeners(SharedEventManagerInterface $sharedEventManager)
{
// Point to the library from core's Import vocabulary page. The page
// has no event of its own, so a notice is added before the layout
// renders its messages. The layout renders only when the page shows,
// including after a failed import, and not when core redirects after
// a successful one.
$sharedEventManager->attach(
'Omeka\Controller\Admin\Vocabulary',
'view.layout',
function (Event $event) {
$view = $event->getTarget();
if ('import' !== $view->params()->fromRoute('action')
|| !$view->userIsAllowed('VocabularyLibrary\Controller\Admin\Index', 'browse')
) {
return;
}
$message = new Message(
'Looking for a published vocabulary? The %s has tested vocabularies, ready to import.', // @translate
$view->hyperlink($view->translate('Vocabulary Library'), $view->url('admin/vocabulary-library'))
);
$message->setEscapeHtml(false);
(new Messenger)->addNotice($message);
}
);
}
}