37 if (isset($params[
"TIMER"]) && $params[
"TIMER"] instanceof
Timer)
38 self::$timer = $params[
"TIMER"];
40 if (!isset($params[
"DATA_SOURCE"]) )
41 throw new ArgumentException(
"DATA_SOURCE must be instanceof DataSource!",
"DATA_SOURCE");
43 if (!isset($params[
"DATA_CONVERTER"]) )
44 throw new ArgumentException(
"DATA_CONVERTER must be instanceof DataConverter!",
"DATA_CONVERTER");
46 if (!isset($params[
"DATA_PROCESSOR"]) || (!($params[
"DATA_PROCESSOR"] instanceof Data\Processors\DataProcessor)))
47 throw new ArgumentException(
"DATA_PROCESSOR must be instanceof DataProcessor!",
"DATA_PROCESSOR");
49 $this->feedType = $params[
"FEED_TYPE"];
50 $this->sourceDataIterator = $params[
"DATA_SOURCE"];
51 $this->dataConvertor = $params[
"DATA_CONVERTER"];
52 $this->dataProcessor = $params[
"DATA_PROCESSOR"];
75 if (!$this->sourceDataIterator)
77 $this->dataProcessor->process(NULL, self::getTimer());
82 $vk = Vk\Vk::getInstance();
83 $executionItemsLimit = $exportId ? $vk->getExecutionItemsLimit($exportId) : Vk\Vk::MAX_EXECUTION_ITEMS;
85 $journal =
new Vk\Journal($exportId, $this->feedType);
87 $logger->addLog(
'Feed start',
'Feed type ' . $this->feedType);
89 $convertedData = array();
91 $nextStepFlag =
false;
93 foreach ($this->sourceDataIterator as $data)
95 $logger->addLog(
'Item to convert',
'ID: ' . $data[
"ID"] .
' NAME: ' . $data[
"NAME"]);
98 $nextStepItem = $data[
"ID"];
102 if ($currData = $this->dataConvertor->convert($data))
104 $convertedData += $currData;
107 if (count($convertedData) >= $executionItemsLimit)
109 $nextStepFlag =
true;
114 if (count($convertedData) > 0)
116 $logger->addLog(
'Items to process',
'Count '.count($convertedData));
117 $this->dataProcessor->process($convertedData, self::getTimer());
118 $logger->addLog(
'Finish process items',
'Count '.count($convertedData));
119 $journal->addItemsCount(count($convertedData));
127 if (count($convertedData) == 0 && $this->feedType ==
'PRODUCTS')
129 $logger->addError(
'EMPTY_SECTION_PRODUCTS');
137 "VK_FEED__FEED_FINISH_OK",
138 'FEED_' . $this->feedType,
139 "VKontakte export of " . $this->feedType .
" for export profile " . $exportId .
" was finished successful. "