oc-social-plugin/console/SocialSync.php

71 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2021-10-28 22:35:15 +02:00
<?php namespace Zoomyboy\Social\Console;
use Illuminate\Console\Command;
use Storage;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
2021-10-30 12:16:27 +02:00
use Zoomyboy\Social\Classes\FacebookService;
use Zoomyboy\Social\Classes\InstagramService;
2021-10-28 22:35:15 +02:00
use Zoomyboy\Social\Models\Setting;
class SocialSync extends Command
{
2021-10-30 12:16:27 +02:00
private $services = [
FacebookService::class,
InstagramService::class,
];
2021-10-28 22:35:15 +02:00
/**
* @var string The console command name.
*/
protected $name = 'social:sync';
/**
* @var string The console command description.
*/
protected $description = 'Synchs social posts';
/**
* Execute the console command.
* @return void
*/
public function handle()
{
2021-10-30 12:16:27 +02:00
foreach ($this->services as $service) {
if ($this->option('clear', false)) {
return app($service)->clearAll();
}
2021-10-28 22:35:15 +02:00
2021-10-30 12:16:27 +02:00
if ($this->option('full', false)) {
app($service)->clearAll();
app($service)->syncAll();
return;
}
2021-10-28 22:35:15 +02:00
2021-10-30 12:16:27 +02:00
app($service)->syncAll();
}
2021-10-28 22:35:15 +02:00
}
/**
* Get the console command arguments.
* @return array
*/
protected function getArguments()
{
return [];
}
/**
* Get the console command options.
* @return array
*/
protected function getOptions()
{
return [
['clear'],
['full']
];
}
}