[regen-thumb] have regen-thumb ext handle the regen-thumb command
This commit is contained in:
parent
74ad1bf86d
commit
8f86ddaa75
2 changed files with 21 additions and 13 deletions
|
@ -110,19 +110,6 @@ class AdminPage extends Extension
|
||||||
$output->writeln($user->get_auth_token());
|
$output->writeln($user->get_auth_token());
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
});
|
});
|
||||||
$event->app->register('regen-thumb')
|
|
||||||
->addArgument('id_or_hash', InputArgument::REQUIRED)
|
|
||||||
->setDescription("Regenerate a post's thumbnail")
|
|
||||||
->setCode(function (InputInterface $input, OutputInterface $output): int {
|
|
||||||
$uid = $input->getArgument('id_or_hash');
|
|
||||||
$image = Image::by_id_or_hash($uid);
|
|
||||||
if ($image) {
|
|
||||||
send_event(new ThumbnailGenerationEvent($image, true));
|
|
||||||
} else {
|
|
||||||
$output->writeln("No post with ID '$uid'\n");
|
|
||||||
}
|
|
||||||
return Command::SUCCESS;
|
|
||||||
});
|
|
||||||
$event->app->register('cache:get')
|
$event->app->register('cache:get')
|
||||||
->addArgument('key', InputArgument::REQUIRED)
|
->addArgument('key', InputArgument::REQUIRED)
|
||||||
->setDescription("Get a cache value")
|
->setDescription("Get a cache value")
|
||||||
|
|
|
@ -4,6 +4,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shimmie2;
|
namespace Shimmie2;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\{InputInterface,InputArgument};
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
class RegenThumb extends Extension
|
class RegenThumb extends Extension
|
||||||
{
|
{
|
||||||
/** @var RegenThumbTheme */
|
/** @var RegenThumbTheme */
|
||||||
|
@ -160,4 +164,21 @@ class RegenThumb extends Extension
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCliGen(CliGenEvent $event): void
|
||||||
|
{
|
||||||
|
$event->app->register('regen-thumb')
|
||||||
|
->addArgument('id_or_hash', InputArgument::REQUIRED)
|
||||||
|
->setDescription("Regenerate a post's thumbnail")
|
||||||
|
->setCode(function (InputInterface $input, OutputInterface $output): int {
|
||||||
|
$uid = $input->getArgument('id_or_hash');
|
||||||
|
$image = Image::by_id_or_hash($uid);
|
||||||
|
if ($image) {
|
||||||
|
send_event(new ThumbnailGenerationEvent($image, true));
|
||||||
|
} else {
|
||||||
|
$output->writeln("No post with ID '$uid'\n");
|
||||||
|
}
|
||||||
|
return Command::SUCCESS;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue