Skip to content

Commit

Permalink
allow to bypass immediate in generate conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Oct 19, 2024
1 parent 123acbb commit d1693f4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Commands/GenerateMediaConversionsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

class GenerateMediaConversionsCommand extends Command
{
public $signature = 'media:generate-conversions {ids?*} {--force} {--pretend} {--conversions=*} {--collections=*} {--models=*}';
public $signature = 'media:generate-conversions {ids?*} {--force} {--immediate} {--pretend} {--conversions=*} {--collections=*} {--models=*}';

public $description = 'Generate all media conversions';

public function handle(): int
{
$ids = (array) $this->argument('ids');
$immediate = (bool) $this->option('immediate');
$force = (bool) $this->option('force');
$pretend = (bool) $this->option('pretend');
/** @var string[] $conversions */
Expand Down Expand Up @@ -46,15 +47,17 @@ public function handle(): int

$progress = new Progress('Dispatching Media conversions', $count);

$query->chunkById(5_000, function ($items) use ($progress, $force, $conversions) {
$query->chunkById(5_000, function ($items) use ($progress, $force, $immediate, $conversions) {

foreach ($items as $media) {
/** @var Media $media */
$media->dispatchConversions(
queued: true,
filter: function ($definition) use ($media, $force, $conversions) {
filter: function ($definition) use ($media, $force, $immediate, $conversions) {

if (! $definition->immediate) {
if (
$immediate === false && ! $definition->immediate
) {
return false;
}

Expand Down

0 comments on commit d1693f4

Please sign in to comment.