mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 01:03:13 +08:00
Created specs for API key roles
This commit is contained in:
28
module/Core/src/ShortUrl/Spec/BelongsToApiKey.php
Normal file
28
module/Core/src/ShortUrl/Spec/BelongsToApiKey.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\ShortUrl\Spec;
|
||||
|
||||
use Happyr\DoctrineSpecification\BaseSpecification;
|
||||
use Happyr\DoctrineSpecification\Filter\Filter;
|
||||
use Happyr\DoctrineSpecification\Spec;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
|
||||
class BelongsToApiKey extends BaseSpecification
|
||||
{
|
||||
private ApiKey $apiKey;
|
||||
private string $dqlAlias;
|
||||
|
||||
public function __construct(ApiKey $apiKey, ?string $dqlAlias = null)
|
||||
{
|
||||
$this->dqlAlias = $dqlAlias ?? 's';
|
||||
$this->apiKey = $apiKey;
|
||||
parent::__construct($this->dqlAlias);
|
||||
}
|
||||
|
||||
protected function getSpec(): Filter
|
||||
{
|
||||
return Spec::eq('authorApiKey', $this->apiKey, $this->dqlAlias);
|
||||
}
|
||||
}
|
||||
27
module/Core/src/ShortUrl/Spec/BelongsToDomain.php
Normal file
27
module/Core/src/ShortUrl/Spec/BelongsToDomain.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\ShortUrl\Spec;
|
||||
|
||||
use Happyr\DoctrineSpecification\BaseSpecification;
|
||||
use Happyr\DoctrineSpecification\Filter\Filter;
|
||||
use Happyr\DoctrineSpecification\Spec;
|
||||
|
||||
class BelongsToDomain extends BaseSpecification
|
||||
{
|
||||
private int $domainId;
|
||||
private string $dqlAlias;
|
||||
|
||||
public function __construct(int $domainId, ?string $dqlAlias = null)
|
||||
{
|
||||
$this->domainId = $domainId;
|
||||
$this->dqlAlias = $dqlAlias ?? 's';
|
||||
parent::__construct($this->dqlAlias);
|
||||
}
|
||||
|
||||
protected function getSpec(): Filter
|
||||
{
|
||||
return Spec::eq('domain', $this->domainId, $this->dqlAlias);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user