mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 01:03:13 +08:00
Simplify ApiKey entity by exposing key as a readonly prop
This commit is contained in:
@@ -8,7 +8,6 @@ use Cake\Chronos\Chronos;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use ReflectionObject;
|
||||
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
|
||||
use Shlinkio\Shlink\Rest\ApiKey\Model\ApiKeyMeta;
|
||||
use Shlinkio\Shlink\Rest\ApiKey\Model\RoleDefinition;
|
||||
@@ -51,12 +50,7 @@ class ApiKeyFixture extends AbstractFixture implements DependentFixtureInterface
|
||||
|
||||
private function buildApiKey(string $key, bool $enabled, Chronos|null $expiresAt = null): ApiKey
|
||||
{
|
||||
$apiKey = ApiKey::fromMeta(ApiKeyMeta::fromParams(expirationDate: $expiresAt));
|
||||
$ref = new ReflectionObject($apiKey);
|
||||
$keyProp = $ref->getProperty('key');
|
||||
$keyProp->setAccessible(true);
|
||||
$keyProp->setValue($apiKey, $key);
|
||||
|
||||
$apiKey = ApiKey::fromMeta(ApiKeyMeta::fromParams(key: $key, expirationDate: $expiresAt));
|
||||
if (! $enabled) {
|
||||
$apiKey->disable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user