Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spiral/http-auth] Injector for TokenStorage #914

Open
butschster opened this issue Apr 5, 2023 · 0 comments
Open

[spiral/http-auth] Injector for TokenStorage #914

butschster opened this issue Apr 5, 2023 · 0 comments

Comments

@butschster
Copy link
Member

<?php

declare(strict_types=1);

namespace App\Application\Injector;

use Spiral\Auth\TokenStorageInterface;
use Spiral\Auth\TokenStorageProviderInterface;

final class TokenProviderInjector implements \Spiral\Core\Container\InjectorInterface
{
    public function __construct(
        private TokenStorageProviderInterface $tokenStorageProvider,
    ) {
    }

    public function createInjection(\ReflectionClass $class, string $context = null): TokenStorageInterface
    {
        if (str_ends_with($context, 'StorageProvider')) {
            return $this->tokenStorageProvider->getStorage(substr($context, -15));
        }

        return $this->tokenStorageProvider->getStorage();
    }
}
@butschster butschster added this to the 3.7 milestone Apr 5, 2023
@butschster butschster modified the milestones: 3.7, 3.8 Apr 18, 2023
@butschster butschster modified the milestones: 3.8, 3.9 Aug 15, 2023
@butschster butschster modified the milestones: 3.9, 3.11 Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant