本文整理汇总了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;
}
}
示例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);
}
}
}
}
}
}
示例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']) {
//.........这里部分代码省略.........