Skip to content

Commit

Permalink
[TASK] Remove ObjectManager from avatar provider
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminkott committed May 12, 2023
1 parent 8587ea1 commit e9ad4ca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions Classes/AvatarProvider/GravatarProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Object\ObjectManager;

class GravatarProvider implements AvatarProviderInterface, SingletonInterface
{
Expand Down Expand Up @@ -62,8 +61,7 @@ final public function __construct()

public function getAvatarUrl(Author $author, int $size): string
{
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
$configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class);
$settings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog');

$rating = empty($rating = (string)($settings['authors']['avatar']['provider']['rating'] ?? '')) ? null : $rating;
Expand Down
4 changes: 1 addition & 3 deletions Classes/AvatarProvider/ImageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Service\ImageService;

class ImageProvider implements AvatarProviderInterface
Expand All @@ -23,8 +22,7 @@ public function getAvatarUrl(Author $author, int $size): string
{
$image = $author->getImage();
if ($image instanceof FileReference) {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$imageService = $objectManager->get(ImageService::class);
$imageService = GeneralUtility::makeInstance(ImageService::class);
$image = $imageService->getImage('', $image, false);

if ($image->hasProperty('crop') && $image->getProperty('crop')) {
Expand Down

0 comments on commit e9ad4ca

Please sign in to comment.