Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
196 additions
and
138 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the NucleosUserAdminBundle package. | ||
* | ||
* (c) Christian Gripp <mail@core23.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Nucleos\UserAdminBundle\Twig; | ||
|
||
use Nucleos\UserAdminBundle\Avatar\AvatarResolver; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
use Twig\Extension\RuntimeExtensionInterface; | ||
|
||
final class AvatarRuntime implements RuntimeExtensionInterface | ||
{ | ||
private AvatarResolver $avatarResolver; | ||
|
||
public function __construct(AvatarResolver $avatarResolver) | ||
{ | ||
$this->avatarResolver = $avatarResolver; | ||
} | ||
|
||
public function userAvatar(?UserInterface $user): string | ||
{ | ||
return $this->avatarResolver->avatarUrl($user); | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the NucleosUserAdminBundle package. | ||
* | ||
* (c) Christian Gripp <mail@core23.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Nucleos\UserAdminBundle\Twig; | ||
|
||
use Symfony\Component\Routing\RouterInterface; | ||
use Twig\Extension\RuntimeExtensionInterface; | ||
|
||
final class ImpersonateRuntime implements RuntimeExtensionInterface | ||
{ | ||
private RouterInterface $router; | ||
|
||
private ?string $route; | ||
|
||
/** | ||
* @var array<string, mixed> | ||
*/ | ||
private $routeParams; | ||
|
||
/** | ||
* @param array<string, mixed> $routeParams | ||
*/ | ||
public function __construct(RouterInterface $router, ?string $route, array $routeParams) | ||
{ | ||
$this->router = $router; | ||
$this->route = $route; | ||
$this->routeParams = $routeParams; | ||
} | ||
|
||
public function switchRoute(string $username): string | ||
{ | ||
if (null === $this->route) { | ||
return '#'; | ||
} | ||
|
||
return $this->router->generate($this->route, array_merge($this->routeParams, ['_switch_user' => $username])); | ||
} | ||
|
||
public function exitRoute(): string | ||
{ | ||
return $this->switchRoute('_exit'); | ||
} | ||
} |
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
Oops, something went wrong.