2024-04-20 23:27:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands\Bundle;
|
|
|
|
|
|
|
|
use App\Classes\Bundle;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
|
|
|
|
class Upgrade extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'bundle:upgrade { path? : Specific bundle to upgrade }';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Upgrade bundles from previous CMS version';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$disk = Storage::disk(env('CONTENT_DISK'));
|
|
|
|
$path = $this->argument('path') ?? '/';
|
|
|
|
$bundles = Bundle::findBundles($disk, $path, true);
|
|
|
|
|
|
|
|
foreach ($bundles as $bundle) {
|
|
|
|
$this->output->write(sprintf('Upgrading %s... ', $bundle->getPath()));
|
|
|
|
|
2024-04-26 13:47:21 +02:00
|
|
|
$currentOtherKeywords = $bundle->metadata('metadata')->get('Autres mots-clé', []);
|
|
|
|
$currentKeywords = $bundle->metadata('metadata')->get('Mots-clé', []);
|
|
|
|
$merged = array_replace_recursive($currentKeywords, $currentOtherKeywords);
|
2024-04-26 12:50:38 +02:00
|
|
|
|
2024-04-26 13:47:21 +02:00
|
|
|
if (!empty($merged)) {
|
|
|
|
$bundle->metadata('metadata')->set('Autres mots-clé', $merged);
|
|
|
|
$bundle->metadata('metadata')->remove('Mots-clé');
|
2024-04-26 12:50:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$currentPeople = $bundle->metadata('metadata')->get('miscPeople');
|
|
|
|
|
|
|
|
if (!empty($currentPeople)) {
|
|
|
|
$bundle->metadata('metadata')->set('Personnalités', $currentPeople);
|
|
|
|
$bundle->metadata('metadata')->remove('miscPeople');
|
|
|
|
}
|
|
|
|
|
|
|
|
$currentLinks = $bundle->metadata('metadata')->get('links');
|
|
|
|
|
|
|
|
if (!empty($currentLinks)) {
|
|
|
|
$bundle->metadata('metadata')->set('Liens', $currentLinks);
|
|
|
|
$bundle->metadata('metadata')->remove('links');
|
2024-04-23 11:58:51 +02:00
|
|
|
}
|
|
|
|
|
2024-04-26 12:50:38 +02:00
|
|
|
$currentDetails = $bundle->metadata('metadata')->get('details');
|
2024-04-23 11:58:51 +02:00
|
|
|
|
2024-04-26 12:50:38 +02:00
|
|
|
if (!empty($currentDetails)) {
|
|
|
|
$bundle->metadata('metadata')->set('Détails', $currentDetails);
|
|
|
|
$bundle->metadata('metadata')->remove('details');
|
|
|
|
}
|
|
|
|
|
|
|
|
$currentTheme = $bundle->metadata('metadata')->get('theme');
|
|
|
|
|
|
|
|
if (!empty($currentTheme)) {
|
|
|
|
$bundle->metadata('metadata')->set('Thème', $currentTheme);
|
|
|
|
$bundle->metadata('metadata')->remove('theme');
|
|
|
|
}
|
|
|
|
|
|
|
|
$currentSagas = $bundle->metadata('metadata')->get('sagas');
|
|
|
|
|
|
|
|
if (!empty($currentSagas)) {
|
|
|
|
$bundle->metadata('metadata')->set('Sagas.Fait partie de', $currentSagas);
|
|
|
|
$bundle->metadata('metadata')->remove('sagas');
|
|
|
|
}
|
2024-04-23 11:58:51 +02:00
|
|
|
|
2024-04-26 12:50:38 +02:00
|
|
|
$bundle->save();
|
2024-04-23 11:58:51 +02:00
|
|
|
|
2024-05-03 16:16:01 +02:00
|
|
|
$toDelete = [
|
|
|
|
'attachments.json',
|
|
|
|
'index.json',
|
|
|
|
'metadata.json',
|
|
|
|
'links.json',
|
|
|
|
];
|
|
|
|
|
|
|
|
foreach ($toDelete as $file) {
|
|
|
|
$bundle->getDisk()->delete($bundle->getPath() . $file);
|
|
|
|
}
|
|
|
|
|
2024-04-20 23:27:47 +02:00
|
|
|
$this->info('OK');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|