-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] intercept errors when API connection fails, logging, messages
- Loading branch information
1 parent
d20ec87
commit 1bfc656
Showing
12 changed files
with
176 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pixelant\Qbank\Utility; | ||
|
||
use TYPO3\CMS\Core\Context\Context; | ||
use TYPO3\CMS\Core\Log\LogManager; | ||
use TYPO3\CMS\Core\Messaging\FlashMessage; | ||
use TYPO3\CMS\Core\Messaging\FlashMessageQueue; | ||
use TYPO3\CMS\Core\Messaging\FlashMessageService; | ||
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
/** | ||
* Convenience methods relating to TYPO3 messaging. | ||
*/ | ||
class MessageUtility | ||
{ | ||
public static function enqueueMessage( | ||
string $message, | ||
string $title = '', | ||
ContextualFeedbackSeverity $severity = ContextualFeedbackSeverity::OK | ||
): void { | ||
$context = GeneralUtility::makeInstance(Context::class); | ||
$beUserId = $context->getPropertyFromAspect('backend.user', 'id'); | ||
|
||
if ($beUserId > 0) { | ||
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); | ||
$notificationQueue = $flashMessageService->getMessageQueueByIdentifier( | ||
FlashMessageQueue::NOTIFICATION_QUEUE | ||
); | ||
$flashMessage = GeneralUtility::makeInstance( | ||
FlashMessage::class, | ||
$message, | ||
$title, | ||
$severity, | ||
true | ||
); | ||
$notificationQueue->enqueue($flashMessage); | ||
} | ||
|
||
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); | ||
$logger->error($message . PHP_EOL . $title); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<f:if condition="{apiStatus -> f:count()}"> | ||
<div role="alert" class="alert alert-danger alert-dismissible"> | ||
<div class="media"> | ||
<div class="media-body"> | ||
<h4 class="alert-title">{f:translate(key: 'LLL:EXT:qbank/Resources/Private/Language/locallang_mod_qbank.xlf:api_error')}</h4> | ||
<p class="alert-message">{apiStatus.errorMessage}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</f:if> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters