当前位置: 首页>>代码示例>>PHP>>正文


PHP Rest::delete方法代码示例

本文整理汇总了PHP中Rest::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Rest::delete方法的具体用法?PHP Rest::delete怎么用?PHP Rest::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rest的用法示例。


在下文中一共展示了Rest::delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _clean

 public static function _clean($destination, $source, $syncTaskId = 0, $whitelist = array())
 {
     $service = ServicesModel::first(array('library' => 'Calendar'))->toArray();
     $task = TasksServicesModel::first(array('task_id' => $syncTaskId, 'service_id' => $service['id']))->toArray();
     $task['stats'] = json_decode($task['stats'], true);
     // Calendars
     $calendars = CalendarsModel::all(array('user_id' => $source['username']['id'], 'sync_task_id' => $syncTaskId))->toArray();
     // Events
     $toDeleteEvents = array();
     $migratedEvents = MigratedDataModel::all(array('source_id' => $source['username']['id'], 'sync_task_id' => $syncTaskId, 'kind' => static::$kind['event']));
     if ($migratedEvents) {
         $migratedEvents = $migratedEvents->toArray();
         if ($migratedEvents) {
             $destinationCalendars = CalendarsModel::all(array('user_id' => $destination['username']['id'], 'sync_task_id' => $syncTaskId));
             if ($destinationCalendars) {
                 $destinationCalendars = $destinationCalendars->toArray();
                 if ($destinationCalendars) {
                     foreach ($destinationCalendars as $calendar) {
                         // get events
                         $newEvents = array();
                         do {
                             $payload = array('maxResults' => static::$limit);
                             if (isset($events['nextPageToken'])) {
                                 $payload['pageToken'] = $events['nextPageToken'];
                             }
                             $events = \Rest::get(sprintf(static::$endpoints['events'], $calendar['calendar_id']), $payload, $destination);
                             if (isset($events['result']['error'])) {
                                 d(static::$endpoints['events']);
                             }
                             if (isset($events['items'])) {
                                 foreach ($events['items'] as $event) {
                                     if (isset($event['summary'])) {
                                         $newEvents[static::identifier($event, $calendar)] = $event['id'];
                                     }
                                 }
                             }
                         } while (isset($events['nextPageToken']) && $events['nextPageToken']);
                         // Mark events
                         foreach ($migratedEvents as $event) {
                             if (isset($newEvents[$event['unique']])) {
                                 $toDeleteEvents[] = array('eventId' => $newEvents[$event['unique']], 'calendarId' => $calendar['calendar_id']);
                             }
                         }
                     }
                 }
             }
         }
     }
     switch (true) {
         # Share / Clean
         ############################################################################
         case !empty($whitelist):
             // Calendars
             if ($calendars) {
                 foreach ($calendars as $calendar) {
                     if (isset($whitelist['calendars']) && in_array($calendar['calendar_id'], $whitelist['calendars'])) {
                         \Rest::delete('https://www.googleapis.com/calendar/v3/calendars/' . $calendar['calendar_id'], array(), $destination);
                     }
                 }
             }
             break;
             # Move
             ############################################################################
         # Move
         ############################################################################
         case $destination['username']['id'] == $source['username']['id']:
             // Calendars
             if ($calendars) {
                 foreach ($calendars as $calendar) {
                     \Rest::delete('https://www.googleapis.com/calendar/v3/calendars/' . $calendar['calendar_id'], array(), $destination);
                 }
             }
             # Migrate / Sync
             ############################################################################
         # Migrate / Sync
         ############################################################################
         default:
             // Calendars
             if ($calendars && $task['stats']['calendars']) {
                 foreach ($calendars as $calendar) {
                     if ($calendar['calendar_new_id']) {
                         \Rest::delete('https://www.googleapis.com/calendar/v3/calendars/' . $calendar['calendar_new_id'], array(), $destination);
                     }
                 }
             }
             // Events
             if ($toDeleteEvents && $task['stats']['events']) {
                 foreach ($toDeleteEvents as $event) {
                     \Rest::delete('https://www.googleapis.com/calendar/v3/calendars/' . $event['calendarId'] . '/events/' . $event['eventId'], array(), $destination);
                 }
             }
             break;
     }
 }
开发者ID:unDemian,项目名称:gcdc-migrate,代码行数:94,代码来源:Calendar.php

示例2: _clean

 public static function _clean($destination, $source, $syncTaskId = 0, $whitelist = array())
 {
     $service = ServicesModel::first(array('library' => 'Tasks'))->toArray();
     $task = TasksServicesModel::first(array('task_id' => $syncTaskId, 'service_id' => $service['id']))->toArray();
     $task['stats'] = json_decode($task['stats'], true);
     // lists
     $lists = BackupsModel::all(array('user_id' => $source['username']['id'], 'sync_task_id' => $syncTaskId, 'entity_type' => static::$kind['list']))->toArray();
     if ($lists && ($task['stats']['lists'] || $destination['username']['id'] == $source['username']['id'])) {
         foreach ($lists as $list) {
             // $whitelist - shared or clean data
             if ($whitelist) {
                 if (isset($whitelist['lists']) && in_array($list['entity_id'], $whitelist['lists'])) {
                     \Rest::delete('https://www.googleapis.com/tasks/v1/users/@me/lists/' . $list['entity_id'], array(), $destination);
                 }
             } else {
                 if ($destination['username']['id'] == $source['username']['id']) {
                     \Rest::delete('https://www.googleapis.com/tasks/v1/users/@me/lists/' . $list['entity_id'], array(), $destination);
                 } else {
                     if ($list['entity_new_id']) {
                         \Rest::delete('https://www.googleapis.com/tasks/v1/users/@me/lists/' . $list['entity_new_id'], array(), $destination);
                     }
                 }
             }
         }
     }
 }
开发者ID:unDemian,项目名称:gcdc-migrate,代码行数:26,代码来源:Tasks.php

示例3: _clean

 public static function _clean($destination, $source, $syncTaskId = 0, $whitelist = array())
 {
     $service = ServicesModel::first(array('library' => 'Youtube'))->toArray();
     $task = TasksServicesModel::first(array('task_id' => $syncTaskId, 'service_id' => $service['id']))->toArray();
     $task['stats'] = json_decode($task['stats'], true);
     // Playlists
     $playlists = PlaylistsModel::all(array('user_id' => $source['username']['id'], 'sync_task_id' => $syncTaskId))->toArray();
     // Videos
     $videos = array();
     $migratedVideos = MigratedDataModel::all(array('source_id' => $source['username']['id'], 'sync_task_id' => $syncTaskId, 'kind' => static::$kind['video']));
     if ($migratedVideos) {
         $migratedVideos = $migratedVideos->toArray();
         if ($migratedVideos) {
             $destinationPlaylists = PlaylistsModel::all(array('user_id' => $destination['username']['id'], 'sync_task_id' => $syncTaskId));
             if ($destinationPlaylists) {
                 $destinationPlaylists = $destinationPlaylists->toArray();
                 if ($destinationPlaylists) {
                     foreach ($destinationPlaylists as $playlist) {
                         foreach ($migratedVideos as $video) {
                             $payload = array('part' => static::$part['playlistItems']['minimal'], 'playlistId' => $playlist['youtube_playlist_id'], 'videoId' => $video['identifier']);
                             $vids = array();
                             $vids = \Rest::get(static::$endpoints['playlistItems'], $payload, $destination);
                             if (isset($vids['result']['error'])) {
                                 d($vids);
                             }
                             if ($vids && $vids['items']) {
                                 foreach ($vids['items'] as $vid) {
                                     $videos[] = $vid['id'];
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Subscriptions
     $newSubscriptions = array();
     $oldSubscriptions = MigratedDataModel::all(array('destination_id' => $destination['username']['id'], 'sync_task_id' => $syncTaskId))->column('identifier');
     do {
         $payload = array('part' => static::$part['subscriptions']['minimal'], 'mine' => 'true', 'maxResults' => static::$limit);
         if (isset($subscriptions['nextPageToken'])) {
             $payload['pageToken'] = $subscriptions['nextPageToken'];
         }
         $subscriptions = \Rest::get(static::$endpoints['subscriptions'], $payload, $destination);
         if (isset($subscriptions['result']['error'])) {
             d($subscriptions);
         }
         if ($subscriptions['items']) {
             foreach ($subscriptions['items'] as $sub) {
                 $newSubscriptions[] = $sub;
             }
         }
     } while (isset($subscriptions['nextPageToken']) && $subscriptions['nextPageToken']);
     switch (true) {
         # Share / Clean
         ############################################################################
         case !empty($whitelist):
             // Playlist
             if ($playlists) {
                 foreach ($playlists as $playlist) {
                     if (isset($whitelist['playlists']) && in_array($playlist['youtube_playlist_id'], $whitelist['playlists'])) {
                         \Rest::delete(static::$endpoints['playlists'], array('id' => $playlist['youtube_playlist_id']), $destination);
                     }
                 }
             }
             // Subscriptions
             if ($newSubscriptions) {
                 foreach ($newSubscriptions as $sub) {
                     if (isset($whitelist['subscriptions']) && in_array($sub['snippet']['resourceId']['channelId'], $whitelist['subscriptions'])) {
                         \Rest::delete(static::$endpoints['subscriptions'], array('id' => $sub['id']), $destination);
                     }
                 }
             }
             break;
             # Move
             ############################################################################
         # Move
         ############################################################################
         case $destination['username']['id'] == $source['username']['id']:
             // Playlist
             if ($playlists) {
                 foreach ($playlists as $playlist) {
                     \Rest::delete(static::$endpoints['playlists'], array('id' => $playlist['youtube_playlist_id']), $destination);
                 }
             }
             // Subscriptions
             if ($newSubscriptions) {
                 foreach ($newSubscriptions as $sub) {
                     \Rest::delete(static::$endpoints['subscriptions'], array('id' => $sub['id']), $destination);
                 }
             }
             break;
             # Migrate / Sync
             ############################################################################
         # Migrate / Sync
         ############################################################################
         default:
             // Playlist
             if ($playlists && $task['stats']['playlists']) {
//.........这里部分代码省略.........
开发者ID:unDemian,项目名称:gcdc-migrate,代码行数:101,代码来源:Youtube.php


注:本文中的Rest::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。