/**
  * @param array $incomingFieldArray
  * @param string $table
  * @param int $id
  * @param \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler
  */
 public function processDatamap_preProcessFieldArray(array &$incomingFieldArray, $table, $id, \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler)
 {
     if ('tx_storelocator_domain_model_store' !== $table) {
         return;
     }
     $incomingFieldArray['address'] = \Aijko\StoreLocator\Utility\GoogleUtility::getFullAddressFromUserData($incomingFieldArray);
 }
Esempio n. 2
0
 /**
  * @return bool
  */
 public function execute()
 {
     $csvData = $this->getCsvData($this->csvPath);
     if (count($csvData) > 0) {
         $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
         $propertyMapper = $objectManager->get('TYPO3\\CMS\\Extbase\\Property\\PropertyMapper');
         $this->persistenceManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
         $this->storeRepository = $objectManager->get('Aijko\\StoreLocator\\Domain\\Repository\\StoreRepository');
         $this->countryRepository = $objectManager->get('SJBR\\StaticInfoTables\\Domain\\Repository\\CountryRepository');
         if ($this->truncate) {
             // Remove all stores
             $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_storelocator_domain_model_store', 'pid = ' . $this->storagePid);
         }
         foreach ($csvData as $row) {
             $setCountry = FALSE;
             if (array_key_exists('country', $row)) {
                 $country = $this->countryRepository->findOneByIsoCodeA2($row['country']);
                 if ($country) {
                     $setCountry = TRUE;
                 }
                 unset($row['country']);
             }
             $store = $propertyMapper->convert($row, 'Aijko\\StoreLocator\\Domain\\Model\\Store');
             $address = \Aijko\StoreLocator\Utility\GoogleUtility::getFullAddressFromUserData($row);
             // Import with task:GeoTask
             #$data = \Aijko\StoreLocator\Utility\GoogleUtility::getLatLongFromAddress($address);
             #$store->setLatitude($data['latitude']);
             #$store->setLongitude($data['longitude']);
             $store->setAddress($address);
             $store->setPid($this->storagePid);
             if (TRUE === $setCountry) {
                 $store->setCountry($country);
             }
             $this->storeRepository->add($store);
         }
         $this->persistenceManager->persistAll();
     }
     return TRUE;
 }