/** * Update the event with the information returned by the callback. * * @param GetGlobalButtonEvent $event The event being emitted. * * @param string $value The HTML representation of the button. * * @return void */ public function update($event, $value) { if ($value === null) { return; } $event->setHtml($value); $event->stopPropagation(); }
/** * Check the permission for send or preview message button. * * @param GetGlobalButtonEvent $event The event. * * @return void */ public function checkPermissionSendMessageButton(GetGlobalButtonEvent $event) { $environment = $event->getEnvironment(); $dataDefinition = $environment->getDataDefinition(); if ($dataDefinition->getName() !== 'orm_avisota_message_content' || $event->getKey() !== 'send') { return; } $user = BackendUser::getInstance(); if (!$user->isAdmin || !$user->hasAccess('send', 'avisota_newsletter_permission')) { $event->setHtml(''); } }
/** * Clear the button if the User is not admin. * * @param GetGlobalButtonEvent $event The event. * * @return void */ public function getGlobalButton(GetGlobalButtonEvent $event) { if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel') { return; } // FIXME: direct access to BackendUser. if (!\BackendUser::getInstance()->isAdmin) { $event->setHtml(''); } }