Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions Classes/Backend/Avatar/MoveElevatorAvatarProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace MoveElevator\Typo3Toolbox\Backend\Avatar;

use TYPO3\CMS\Backend\Backend\Avatar\AvatarProviderInterface;
use TYPO3\CMS\Backend\Backend\Avatar\Image;
use TYPO3\CMS\Core\SystemResource\Publishing\SystemResourcePublisherInterface;
use TYPO3\CMS\Core\SystemResource\SystemResourceFactory;

final readonly class MoveElevatorAvatarProvider implements AvatarProviderInterface
{
private const string EMAIL_DOMAIN = '@move-elevator.de';
private const string LOGO_PATH = 'EXT:typo3_toolbox/Resources/Public/Icons/me.svg';

public function __construct(
private SystemResourceFactory $systemResourceFactory,
private SystemResourcePublisherInterface $resourcePublisher,
) {
}

/**
* @param array<int|string, mixed> $backendUser
*/
public function getImage(array $backendUser, mixed $size): ?Image
{
if ((int)($backendUser['avatar'] ?? 0) > 0) {
return null;
}

$email = strtolower((string)($backendUser['email'] ?? ''));
if ($email === '' || !str_ends_with($email, self::EMAIL_DOMAIN)) {
return null;
}

$resource = $this->systemResourceFactory->createPublicResource(self::LOGO_PATH);

return new Image(
(string)$this->resourcePublisher->generateUri($resource, null),
$size,
$size,
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This extension provides several tools for TYPO3 integrators and developers.
- Adds a CSS view helper that enables the rendering of a `noscript` variant and allows inline styles to be replaced by a key-value-based `inlineReplacements` option flag
- Adds a sentry middleware and frontend module ...
- Adds a custom TYPO3 page renderer template which removes some unnecessary spaces and changes the order of inline CSS injection
- Adds a backend avatar provider that assigns the move elevator logo to backend users with an `@move-elevator.de` email address (when no custom avatar is set)

## Version support

Expand Down Expand Up @@ -96,6 +97,12 @@ The `ContentMinifierEventListener` automatically minifies the HTML output of all
| Remove CKEditor data attributes | Strips `data-list-item-id` attributes from `<li>` elements added by CKEditor 5 ([TYPO3#109002](https://forge.typo3.org/issues/109002), [CKEditor5#19006](https://github.com/ckeditor/ckeditor5/issues/19006)) |
| Trim tag content whitespace | Removes leading/trailing whitespace inside `h1`–`h6`, `p`, `li`, `td`, `th`, `dt`, `dd`, `button`, and `label` tags |

### Backend Avatar

The `MoveElevatorAvatarProvider` automatically assigns the move elevator logo (`Resources/Public/Icons/me.svg`) as the backend avatar for any backend user whose email address ends with `@move-elevator.de`.

Personal avatars uploaded via the user settings always take precedence — the logo is only used as a fallback when no custom avatar is configured.

### Middlewares

| Middleware | Path/ Parameter | Description |
Expand Down
Binary file added Resources/Public/Icons/me.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Resources/Public/Icons/me.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use MoveElevator\Typo3Toolbox\Backend\Avatar\MoveElevatorAvatarProvider;
use MoveElevator\Typo3Toolbox\Enumeration\Configuration;
use MoveElevator\Typo3Toolbox\Page\AssetRenderer;
use Networkteam\SentryClient;
Expand All @@ -13,6 +14,10 @@
'className' => AssetRenderer::class,
];

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['getBackendUserAvatar']['moveElevatorAvatar'] = [
'provider' => MoveElevatorAvatarProvider::class,
];

$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(Configuration::EXT_KEY->value);
if ((bool)($extConf['sentryBackendEnabled'] ?? false)) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'] = SentryClient\DebugExceptionHandler::class;
Expand Down