mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
delete static demo when changing demo url
This commit is contained in:
parent
df83a46e20
commit
611e7c3415
5 changed files with 138 additions and 21 deletions
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Demostf\API\Controllers;
|
||||
|
||||
use Demostf\API\Demo\DemoStore;
|
||||
use Demostf\API\Providers\ChatProvider;
|
||||
use Demostf\API\Providers\DemoListProvider;
|
||||
use Demostf\API\Providers\DemoProvider;
|
||||
|
|
@ -21,18 +22,22 @@ class DemoController extends BaseController {
|
|||
|
||||
private $editKey;
|
||||
|
||||
private $store;
|
||||
|
||||
public function __construct(
|
||||
Request $request,
|
||||
Response $response,
|
||||
DemoProvider $demoProvider,
|
||||
ChatProvider $chatProvider,
|
||||
DemoListProvider $demoListProvider,
|
||||
DemoStore $store,
|
||||
string $editKey
|
||||
) {
|
||||
parent::__construct($request, $response);
|
||||
$this->demoProvider = $demoProvider;
|
||||
$this->chatProvider = $chatProvider;
|
||||
$this->demoListProvider = $demoListProvider;
|
||||
$this->store = $store;
|
||||
$this->editKey = $editKey;
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +118,10 @@ class DemoController extends BaseController {
|
|||
$existingHash = $demo->getHash();
|
||||
if ($existingHash === '' || $existingHash === $hash) {
|
||||
$this->demoProvider->setDemoUrl((int) $id, $backend, $url, $path);
|
||||
|
||||
if ($demo->getBackend() === 'static') {
|
||||
$this->store->remove($demo);
|
||||
}
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid demo hash');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue