for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Sylius\ShopApiPlugin\Provider;
use Sylius\Component\Core\Model\ShopUserInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Webmozart\Assert\Assert;
final class CurrentUserProvider implements CurrentUserProviderInterface
{
/**
* @var TokenStorage
*/
private $tokenStorage;
public function __construct(TokenStorage $tokenStorage)
$this->tokenStorage = $tokenStorage;
}
* @return ShopUserInterface
public function provide(): ShopUserInterface
/** @var ShopUserInterface $user */
$user = $this->tokenStorage->getToken()->getUser();
Assert::isInstanceOf($user, ShopUserInterface::class);
return $user;