/** * @return void */ public function testTouchDeletedInsertsSomething() { $touchEntityQuery = $this->touchQueryContainer->queryTouchListByItemType('ProductTranslationWhatever'); $touchCountBeforeTouch = $touchEntityQuery->count(); $this->touchFacade->touchDeleted('ProductTranslationWhatever', 3); $touchCountAfterTouch = $touchEntityQuery->count(); $this->assertTrue($touchCountAfterTouch > $touchCountBeforeTouch); }
/** * @param string $itemType * * @return \Generated\Shared\Transfer\TouchTransfer[] */ public function getItemsByType($itemType) { $entityList = $this->touchQueryContainer->queryTouchListByItemType($itemType)->find(); $items = []; foreach ($entityList as $entity) { $touchTransfer = (new TouchTransfer())->fromArray($entity->toArray()); $items[$entity->getIdTouch()] = $touchTransfer; } return $items; }
/** * @param string $itemType * @param int $offset * * @return \Orm\Zed\Touch\Persistence\SpyTouch[] */ protected function getTouchCollectionToDelete($itemType, $offset = 0) { $deleteQuery = $this->touchQueryContainer->queryTouchDeleteStorageAndSearch($itemType); $deleteQuery->withColumn(SpyTouchTableMap::COL_ID_TOUCH, CollectorConfig::COLLECTOR_TOUCH_ID)->withColumn('search.key', CollectorConfig::COLLECTOR_SEARCH_KEY)->withColumn('storage.key', CollectorConfig::COLLECTOR_STORAGE_KEY)->setOffset($offset)->setLimit($this->chunkSize)->setFormatter(\Propel\Runtime\Formatter\StatementFormatter::class); $params = []; $sql = $deleteQuery->createSelectSql($params); $params = $this->getTouchQueryParameters($deleteQuery); $statement = $this->touchQueryContainer->getConnection()->prepare($sql); $sqlParams = []; $step = 1; foreach ($params as $key => $value) { $sqlParams['p' . $step] = $value; $statement->bindParam(':p' . $step, $value); $step++; } $statement->execute($sqlParams); return $statement->fetchAll(\PDO::FETCH_ASSOC); }
/** * @param string $type * @param \Generated\Shared\Transfer\LocaleTransfer $locale * @param \Symfony\Component\Console\Output\OutputInterface $output * * @return \Spryker\Zed\Collector\Business\Model\BatchResultInterface */ public function exportByType($type, LocaleTransfer $locale, OutputInterface $output) { $result = clone $this->batchResultPrototype; $result->setProcessedLocale($locale); if (!$this->isCollectorRegistered($type)) { $this->resetResult($result); return $result; } $lastRunDatetime = $this->marker->getLastExportMarkByTypeAndLocale($type, $locale); $startTime = new \DateTime(); $baseQuery = $this->queryContainer->createBasicExportableQuery($type, $locale, $lastRunDatetime); $baseQuery->withColumn(SpyTouchTableMap::COL_ID_TOUCH, CollectorConfig::COLLECTOR_TOUCH_ID); $baseQuery->withColumn(SpyTouchTableMap::COL_ITEM_ID, CollectorConfig::COLLECTOR_RESOURCE_ID); $baseQuery->setFormatter($this->getFormatter()); $collectorPlugin = $this->collectorPlugins[$type]; $collectorPlugin->run($baseQuery, $locale, $result, $this->reader, $this->writer, $this->touchUpdater, $output); $this->finishExport($result, $type, $startTime); return $result; }
/** * @param string $itemType * @param array $itemIdChunk * * @return array */ protected function getIdCollection($itemType, array $itemIdChunk) { $touchQuery = $this->touchQueryContainer->queryTouchEntriesByItemTypeAndItemIds($itemType, $itemIdChunk); return $touchQuery->select([SpyTouchTableMap::COL_ITEM_ID])->find()->toArray(); }
/** * @param array $types * * @return array */ protected function getAvailableCollectorTypes(array $types) { $availableTypes = $this->touchQueryContainer->queryExportTypes()->find(); return array_unique(array_merge($types, $availableTypes)); }
/** * Removes Touch data in any of the database tables for Collectors * If a different Collector table is added to the system, this code should * be updated or overridden to include covering that table as well * * @param array $touchIds * * @return void */ protected function removeTouchDataForCollectors(array $touchIds) { $this->touchQueryContainer->queryTouchSearchByTouchIds($touchIds)->delete(); $this->touchQueryContainer->queryTouchStorageByTouchIds($touchIds)->delete(); }