48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Domain\Catalog\LicenseArticle;
|
|
use App\Domain\Catalog\Offer;
|
|
use App\Domain\Catalog\OfferService;
|
|
use App\Domain\Catalog\RightsProfileVersion;
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
|
|
if ($argc < 7) {
|
|
fwrite(STDERR, "Aufruf: offer_activate_worker.php <db-pfad> <offer-id> <artikel-id> <rechte-id> <preis-cents> <delay-ms>\n");
|
|
exit(2);
|
|
}
|
|
|
|
$database = $argv[1];
|
|
$offerId = (int) $argv[2];
|
|
$articleId = (int) $argv[3];
|
|
$rightsId = (int) $argv[4];
|
|
$priceCents = (int) $argv[5];
|
|
$delayMs = (int) $argv[6];
|
|
|
|
putenv('APP_ENV=testing');
|
|
putenv('DB_CONNECTION=sqlite');
|
|
putenv('DB_DATABASE='.$database);
|
|
|
|
require __DIR__.'/../../vendor/autoload.php';
|
|
$app = require __DIR__.'/../../bootstrap/app.php';
|
|
$app->make(Kernel::class)->bootstrap();
|
|
|
|
if ($delayMs > 0) {
|
|
usleep($delayMs * 1000);
|
|
}
|
|
|
|
$offers = app(OfferService::class);
|
|
$offer = Offer::query()->findOrFail($offerId);
|
|
$article = LicenseArticle::query()->findOrFail($articleId);
|
|
$rights = RightsProfileVersion::query()->findOrFail($rightsId);
|
|
|
|
$offers->activate($offer, [
|
|
['target' => $article, 'rights' => $rights],
|
|
], [
|
|
'grant_kind' => 'kauf',
|
|
'price_cents' => $priceCents,
|
|
]);
|
|
|
|
echo "ok\n";
|