- Ajout des fonctions de récupération de Média + XML vers Arcadia - Ajout règles de gestion sur le bouton de liaison Arcadia
75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Media;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class ArcadiaLink extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'arcadialink:process';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command description';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
$this->info('Démarrage du traitement');
|
|
$files = Storage::disk('arcadia_link_r')->files();
|
|
$bar = $this->output->createProgressBar(count($files)-1);
|
|
$bar->start();
|
|
|
|
foreach ($files as $filename) {
|
|
if($filename == ".gitignore" || $filename == ".gitkeep") continue;
|
|
|
|
// ---- Récupération du contenu
|
|
$files = Storage::disk('arcadia_link_r')->get($filename);
|
|
$fileContent = simplexml_load_string($files, null, LIBXML_NOCDATA);
|
|
|
|
$media = Media::find($fileContent->code_DAM);
|
|
$media->arcadia_id = $fileContent->codeArcadia;
|
|
$media->version = $fileContent->version;
|
|
$media->isLocked = 0;
|
|
$media->save();
|
|
|
|
// ---- Index dans Elasticsearch
|
|
$media = Media::find($media->id);
|
|
$esExist = Media::searchByQuery(array('match' => array('arcadia_id' => "$media->arcadia_id")));
|
|
if ($esExist)
|
|
$media->removeFromIndex();
|
|
$media->addToIndex();
|
|
|
|
//Storage::disk('arcadia_link_r')->delete($filename);
|
|
$bar->advance();
|
|
}
|
|
|
|
$bar->finish();
|
|
$this->line("");
|
|
$this->info('Fin du traitement');
|
|
}
|
|
}
|