deblan.io-murph/src/Command/MastodonCommentsSyncCommand.php
Simon Vieille 9dc3272d40
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
[wip] mastodon integration
2023-07-27 18:28:25 +02:00

50 lines
1.5 KiB
PHP

<?php
namespace App\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use App\Api\MastodonClient;
use App\Core\Manager\EntityManager;
use App\Repository\Blog\PostRepositoryQuery;
#[AsCommand(
name: 'app:mastodon:comments-sync',
description: 'Add a short description for your command',
)]
class MastodonCommentsSyncCommand extends Command
{
public function __construct(
protected MastodonClient $client,
protected PostRepositoryQuery $query,
protected EntityManager $manager
)
{
parent::__construct();
}
protected function configure(): void
{
// $this
// ->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
// ->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
// ;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
foreach ($this->query->create()->where('.mastodonUrl is not null')->find() as $post) {
dump($this->client->getTree($this->client->extractId($post->getMastodonUrl())));
}
return Command::SUCCESS;
}
}