Skip to content

Commit

Permalink
feat: Made Gravatar optional with roadiz_core.useGravatar config option
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed May 14, 2024
1 parent 21d725c commit 52842e5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Controllers/Users/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@

namespace Themes\Rozier\Controllers\Users;

use JMS\Serializer\SerializerInterface;
use RZ\Roadiz\Core\AbstractEntities\PersistableInterface;
use RZ\Roadiz\CoreBundle\Entity\Role;
use RZ\Roadiz\CoreBundle\Entity\User;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Themes\Rozier\Controllers\AbstractAdminWithBulkController;
use Themes\Rozier\Forms\UserDetailsType;
use Themes\Rozier\Forms\UserType;
use Twig\Error\RuntimeError;

class UsersController extends AbstractAdminWithBulkController
{
public function __construct(
FormFactoryInterface $formFactory,
SerializerInterface $serializer,
UrlGeneratorInterface $urlGenerator,
private readonly bool $useGravatar
) {
parent::__construct($formFactory, $serializer, $urlGenerator);
}


protected function supports(PersistableInterface $item): bool
{
return $item instanceof User;
Expand Down Expand Up @@ -123,7 +136,7 @@ protected function createUpdateEvent(PersistableInterface $item)
/*
* If pictureUrl is empty, use default Gravatar image.
*/
if ($item->getPictureUrl() == '') {
if ($item->getPictureUrl() == '' && $this->useGravatar) {
$item->setPictureUrl($item->getGravatarUrl());
}

Expand Down

0 comments on commit 52842e5

Please sign in to comment.