Applied API role specs to tag visits

This commit is contained in:
Alejandro Celaya
2021-01-04 11:14:28 +01:00
parent 4a1e7b761a
commit 8aa6bdb934
17 changed files with 214 additions and 37 deletions

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Rest\ApiKey\Spec;
use Happyr\DoctrineSpecification\BaseSpecification;
use Happyr\DoctrineSpecification\Spec;
use Happyr\DoctrineSpecification\Specification\Specification;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
class WithApiKeySpecsEnsuringJoin extends BaseSpecification
{
private ?ApiKey $apiKey;
public function __construct(?ApiKey $apiKey)
{
parent::__construct();
$this->apiKey = $apiKey;
}
protected function getSpec(): Specification
{
return $this->apiKey === null || $this->apiKey->isAdmin() ? Spec::andX() : Spec::andX(
Spec::join('shortUrls', 's'),
$this->apiKey->spec(),
);
}
}