IiifPresentation events

Hey,

I’m working with IiifPresentation module and having a little trouble attaching to its events. First, I’m not sure what to use in the identifier when attaching. I tried use IiifPresentation\v3\Controller\Item but that didn’t seem to work so I’m just using * which does, ie.

$sharedEventManager->attach(
            '*',
            'iiif_presentation.3.item.manifest',
            [$this, 'updateIiifThumbnail']
        );

That works, but I’m wondering if it’s better to more specific. Next issue, which I wonder if it’s related in any is that when I get the item from the parameters it reads as null unless I first check if it exist, which is a little funny but maybe I’m not doing something correctly.

So, if I do something like this it throws an error saying, “Call to a member function id() on null”

$manifest = $event->getParam('manifest');
$item = $event->getParam('item');
echo $item->id();

But if I first check to see if $item has value, everything works as I want it, ie

$manifest = $event->getParam('manifest');
$item = $event->getParam('item');
if ($item) {
    echo $item->id();
...

Thanks,

Joe

I tried use IiifPresentation\v3\Controller\Item but that didn’t seem to work

Yes, that’s a bug. Thanks for reporting it. It should be fixed in the next release which should be published tomorrow.

when I get the item from the parameters it reads as null unless I first check if it exist,

That’s quite strange. It’s possible since you’re using * as an identifier, some other events are bleeding through. I’d upgrade to the new release and see if that fixes it. If not, I’ll take a closer look.

1 Like

By the way, once the fix is up, the correct identifier to use is IiifPresentation\v3\Controller\ItemController.

Thanks, I got the new version installed and the correct identifier works, but I’m still getting that funny thing where it throws an error on the item unless I check first that it has value. Very strange.

I found the problem. Put simply, there was a duplicate event being triggered. It should be fixed in the next version, which should be published tomorrow.

It’s all good now, thanks!

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.