Allow custom API keys to be created

This commit is contained in:
Alejandro Celaya
2023-09-19 09:10:17 +02:00
parent 49bd230474
commit 65a0a90a51
16 changed files with 93 additions and 94 deletions

View File

@@ -6,6 +6,7 @@ namespace Shlinkio\Shlink\Rest\ApiKey\Repository;
use Doctrine\DBAL\LockMode;
use Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository;
use Shlinkio\Shlink\Rest\ApiKey\Model\ApiKeyMeta;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
class ApiKeyRepository extends EntitySpecificationRepository implements ApiKeyRepositoryInterface
@@ -24,7 +25,7 @@ class ApiKeyRepository extends EntitySpecificationRepository implements ApiKeyRe
->getOneOrNullResult();
if ($firstResult === null) {
$em->persist(ApiKey::fromKey($apiKey));
$em->persist(ApiKey::fromMeta(ApiKeyMeta::fromParams(key: $apiKey)));
$em->flush();
}
});