mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-09 16:53:11 +08:00
Create service to delete orphan visits
This commit is contained in:
22
module/Core/src/Visit/VisitsDeleter.php
Normal file
22
module/Core/src/Visit/VisitsDeleter.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Visit;
|
||||
|
||||
use Shlinkio\Shlink\Core\Model\BulkDeleteResult;
|
||||
use Shlinkio\Shlink\Core\Visit\Repository\VisitDeleterRepositoryInterface;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
|
||||
class VisitsDeleter implements VisitsDeleterInterface
|
||||
{
|
||||
public function __construct(private readonly VisitDeleterRepositoryInterface $repository)
|
||||
{
|
||||
}
|
||||
|
||||
public function deleteOrphanVisits(?ApiKey $apiKey = null): BulkDeleteResult
|
||||
{
|
||||
// TODO Check API key has permissions for orphan visits
|
||||
return new BulkDeleteResult($this->repository->deleteOrphanVisits());
|
||||
}
|
||||
}
|
||||
13
module/Core/src/Visit/VisitsDeleterInterface.php
Normal file
13
module/Core/src/Visit/VisitsDeleterInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Visit;
|
||||
|
||||
use Shlinkio\Shlink\Core\Model\BulkDeleteResult;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
|
||||
interface VisitsDeleterInterface
|
||||
{
|
||||
public function deleteOrphanVisits(?ApiKey $apiKey = null): BulkDeleteResult;
|
||||
}
|
||||
Reference in New Issue
Block a user