diff --git a/app/Models/Foundation/Summit/CalendarSync/CalendarSyncInfoCalDav.php b/app/Models/Foundation/Summit/CalendarSync/CalendarSyncInfoCalDav.php index 64dc0fb2..0619c8be 100644 --- a/app/Models/Foundation/Summit/CalendarSync/CalendarSyncInfoCalDav.php +++ b/app/Models/Foundation/Summit/CalendarSync/CalendarSyncInfoCalDav.php @@ -104,6 +104,13 @@ class CalendarSyncInfoCalDav extends CalendarSyncInfo */ public function getServer(){ $result = parse_url($this->user_principal_url); + + if(!$result) throw new \InvalidArgumentException(sprintf("user_principal_url %s is invalid", $this->user_principal_url)); + if(!isset($result['scheme'])) + throw new \InvalidArgumentException(sprintf("user_principal_url %s is invalid", $this->user_principal_url)); + if(!isset($result['host'])) + throw new \InvalidArgumentException(sprintf("user_principal_url %s is invalid", $this->user_principal_url)); + return $result['scheme']."://".$result['host']; } diff --git a/app/Services/Apis/CalendarSync/CalendarSyncRemoteFacadeFactory.php b/app/Services/Apis/CalendarSync/CalendarSyncRemoteFacadeFactory.php index adcc21c3..4653ada4 100644 --- a/app/Services/Apis/CalendarSync/CalendarSyncRemoteFacadeFactory.php +++ b/app/Services/Apis/CalendarSync/CalendarSyncRemoteFacadeFactory.php @@ -13,6 +13,7 @@ **/ use App\Services\Apis\CalendarSync\ICalendarSyncRemoteFacadeFactory; use models\summit\CalendarSync\CalendarSyncInfo; +use Illuminate\Support\Facades\Log; /** * Class CalendarSyncRemoteFacadeFactory * @package services\apis\CalendarSync @@ -24,17 +25,23 @@ final class CalendarSyncRemoteFacadeFactory implements ICalendarSyncRemoteFacade * @return ICalendarSyncRemoteFacade|null */ public function build(CalendarSyncInfo $sync_calendar_info){ - switch($sync_calendar_info->getProvider()){ - case CalendarSyncInfo::ProviderGoogle: - return new GoogleCalendarSyncRemoteFacade($sync_calendar_info); - break; - case CalendarSyncInfo::ProvideriCloud: - return new ICloudCalendarSyncRemoteFacade($sync_calendar_info); - break; - case CalendarSyncInfo::ProviderOutlook: - return new OutlookCalendarSyncRemoteFacade($sync_calendar_info); - break; + try { + switch ($sync_calendar_info->getProvider()) { + case CalendarSyncInfo::ProviderGoogle: + return new GoogleCalendarSyncRemoteFacade($sync_calendar_info); + break; + case CalendarSyncInfo::ProvideriCloud: + return new ICloudCalendarSyncRemoteFacade($sync_calendar_info); + break; + case CalendarSyncInfo::ProviderOutlook: + return new OutlookCalendarSyncRemoteFacade($sync_calendar_info); + break; + } + return null; + } + catch (\Exception $ex){ + Log::warning($ex); + return null; } - return null; } } \ No newline at end of file