oc-social-plugin/console/SocialSync.php

71 lines
1.5 KiB
PHP

<?php namespace Zoomyboy\Social\Console;
use Illuminate\Console\Command;
use Storage;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Zoomyboy\Social\Classes\FacebookService;
use Zoomyboy\Social\Classes\InstagramService;
use Zoomyboy\Social\Models\Setting;
class SocialSync extends Command
{
private $services = [
FacebookService::class,
InstagramService::class,
];
/**
* @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()
{
foreach ($this->services as $service) {
if ($this->option('clear', false)) {
return app($service)->clearAll();
}
if ($this->option('full', false)) {
app($service)->clearAll();
app($service)->syncAll();
return;
}
app($service)->syncAll();
}
}
/**
* Get the console command arguments.
* @return array
*/
protected function getArguments()
{
return [];
}
/**
* Get the console command options.
* @return array
*/
protected function getOptions()
{
return [
['clear'],
['full']
];
}
}