Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
84 righe
2.2 KiB
84 righe
2.2 KiB
<?php |
|
|
|
namespace App\Console\Commands\Preservation; |
|
|
|
use App\Models\Main\Tenant; |
|
use Illuminate\Console\Command; |
|
use App\Classes\PreservationClass; |
|
use Illuminate\Support\Facades\DB; |
|
use App\Jobs\Preservation\GetFilesJob; |
|
use App\Models\Tenant\Conservazione\Conservazione; |
|
|
|
class SendSpecificCollectionsCommand extends Command |
|
{ |
|
/** |
|
* The name and signature of the console command. |
|
* |
|
* @var string |
|
*/ |
|
protected $signature = 'preservation:send |
|
{--T|tenant= : Tenant Identifier} |
|
{--P|package= : Package Identifier}'; |
|
|
|
/** |
|
* The console command description. |
|
* |
|
* @var string |
|
*/ |
|
protected $description = 'Send specific collection'; |
|
|
|
/** |
|
* Create a new command instance. |
|
* |
|
* @return void |
|
*/ |
|
public function __construct() |
|
{ |
|
parent::__construct(); |
|
} |
|
|
|
/** |
|
* Execute the console command. |
|
* |
|
* @return int |
|
*/ |
|
public function handle() |
|
{ |
|
$tenant = $this->option("tenant"); |
|
$package = $this->option("package"); |
|
|
|
setup_db_connection(); |
|
|
|
config(['database.connections.mysql-tenant.database' => config('json.prefix_db') . "_ente{$tenant}"]); |
|
DB::purge('mysql-tenant'); |
|
|
|
$tenant = Tenant::find($tenant); |
|
$collection = Conservazione::where("codice", $package)->first(); |
|
if($collection->tipologia == "conservazione") { |
|
|
|
$collection->stato = 10; |
|
$collection->save(); |
|
|
|
if($collection->items()->count() < 1) { |
|
|
|
$this->line("Getting file for #{$collection->codice}"); |
|
GetFilesJob::dispatchSync($tenant->codice, $collection->codice); |
|
|
|
} |
|
|
|
$settings = json_decode($tenant->conservazione, true)["connettore"] ?? ""; |
|
if($collection->items()->count() > 0 && ! empty($settings)) { |
|
|
|
$this->info("Sending collection: #{$collection->codice}"); |
|
|
|
$preservation = new PreservationClass($tenant->codice, $collection->codice); |
|
$preservation->enableDebugging(); |
|
$preservation->pushCollection(); |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
} |
|
}
|
|
|