Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
albumsdeleteall.php
1<?php
2
4
5
9
15{
22 public function process($data = NULL, Timer $timer = NULL)
23 {
24 $apiHelper = new Vk\Api\ApiHelper($this->exportId);
25 $albumsFromVk = $apiHelper->getALbumsFromVk($this->vkGroupId, false);
26 $albumsMapped = Vk\Map::getMappedAlbums($this->exportId);
27
28// delete ALL from mapping
29 $albumsMappedToRemove = array();
30 foreach ($albumsMapped as $albumMapped)
31 {
32 $albumsMappedToRemove[] = array("VALUE_EXTERNAL" => $albumMapped["ALBUM_VK_ID"]);
33 }
34
35 if (!empty($albumsMappedToRemove))
36 {
37 Vk\Map::removeAlbumMapping($albumsMappedToRemove, $this->exportId);
38 }
39
40
41// formatted data
42 foreach ($albumsFromVk as &$album)
43 {
44 $album = array('ALBUM_VK_ID' => $album);
45 }
46 $albumsFromVk = array_chunk($albumsFromVk, Vk\Vk::MAX_EXECUTION_ITEMS); // max 25 items in execute()
47 foreach ($albumsFromVk as $chunk)
48 {
49 $this->executer->executeMarketAlbumDelete(array(
50 "owner_id" => $this->vkGroupId,
51 "data" => $chunk,
52 "count" => count($chunk),
53 ));
54
55// abstract start position - only for continue export, not for rewind to position
56 if ($timer !== NULL && !$timer->check())
57 throw new TimeIsOverException("Timelimit for export is over", '1');
58 }
59
60// remove products from cache
61 $vkExportedData = new Vk\VkExportedData($this->exportId, 'ALBUMS');
62 $vkExportedData->removeData();
63
64 return true;
65 }
66}