mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 06:20:21 +00:00
57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\Office365\Office365Service;
|
|
use Illuminate\Console\Command;
|
|
|
|
class SyncOffice365 extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'office365:sync';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command description';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$events = Office365Service::getCalendarEvents();
|
|
// determine if event is blocker or subtask. if the first word in event name is project code, then it is subtask. otherwise it is blocker
|
|
|
|
// but first, remove "Canceled: " from the event name in case of canceled event
|
|
$events = array_map(function ($event) {
|
|
if ($event['isCancelled']) {
|
|
$event['subject'] = str_replace('Canceled: ', '', $event['subject']);
|
|
}
|
|
|
|
return $event;
|
|
}, $events);
|
|
|
|
$blockers_from_office365 = Office365Service::getBlockers_from_office_365_events($events);
|
|
$subtasks_from_office365 = Office365Service::getSubtasks_from_office_365_events($events);
|
|
|
|
Office365Service::addBlockers($blockers_from_office365);
|
|
Office365Service::editBlockers($blockers_from_office365);
|
|
Office365Service::removeBlockers($blockers_from_office365);
|
|
|
|
Office365Service::addSubtasks($subtasks_from_office365);
|
|
Office365Service::editSubtasks($subtasks_from_office365);
|
|
Office365Service::removeSubtasks($subtasks_from_office365);
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|