Ajout Commands/ArcadiaLink
This commit is contained in:
parent
ae264bdc96
commit
1c22e7a04d
1 changed files with 74 additions and 0 deletions
74
app/Console/Commands/ArcadiaLink.php
Normal file
74
app/Console/Commands/ArcadiaLink.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?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
|
||||
$id = $media->id;
|
||||
$media = Media::find($id);
|
||||
$media->removeFromIndex();
|
||||
$media->addToIndex();
|
||||
|
||||
//Storage::disk('arcadia_link_r')->delete($filename);
|
||||
$bar->advance();
|
||||
}
|
||||
|
||||
$bar->finish();
|
||||
$this->line("");
|
||||
$this->info('Fin du traitement');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue