PHP code example of konradmichalik / typo3-letter-avatar
1. Go to this page and download the library: Download konradmichalik/typo3-letter-avatar library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
konradmichalik / typo3-letter-avatar example snippets
// Generate avatar entity
$avatar = \KonradMichalik\Typo3LetterAvatar\Image\Avatar::create(
name: 'Konrad Michalik',
mode: KonradMichalik\Typo3LetterAvatar\Enum\ColorMode::RANDOM
);
// Save avatar image to default path
$avatar->save();
// Get web path of generated image
$avatar->getWebPath();
declare(strict_types=1);
namespace Vendor\Package\EventListener;
use KonradMichalik\Typo3LetterAvatar\Enum\ColorMode;
use KonradMichalik\Typo3LetterAvatar\Event\BackendUserAvatarConfigurationEvent;
class ModifyLetterAvatarEventListener
{
public function __invoke(BackendUserAvatarConfigurationEvent $event): void
{
$backendUser = $event->getBackendUser();
/*
* Example: If the backend user is an admin, set the CUSTOM color mode and define custom colors.
*/
if ($backendUser['admin'] === 1) {
$configuration = $event->getConfiguration();
$configuration['mode'] = ColorMode::CUSTOM;
$configuration['foreground'] = '#000000';
$configuration['background'] = '#FFFFFF';
$event->setConfiguration($configuration);
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.