/**
  * action sync
  *
  * @param \Aijko\SharepointConnector\Domain\Model\Mapping\Lists $list
  * @return void
  */
 public function syncAction(\Aijko\SharepointConnector\Domain\Model\Mapping\Lists $list)
 {
     $GLOBALS['typo3CacheManager']->flushCachesByTag('spc_list_attributes');
     $sharepointAttributes = $this->sharepointListsRepository->findAttributesByListIdentifier($list->getSharepointListIdentifier());
     $typo3ListAttributes = $list->getAttributes();
     if ($sharepointAttributes) {
         // Sync sharepoint attributes with TYPO3 attributes
         $newAttributes = \Aijko\SharepointConnector\Utility\Attribute::syncAttributesAndFindAllNewOnes($sharepointAttributes, $typo3ListAttributes);
         $this->view->assign('newAttributes', $newAttributes);
         // Sync TYPO3 attributes with sharepoint attributes to find out all deprecated attributes
         $deprecatedAttributes = \Aijko\SharepointConnector\Utility\Attribute::syncAttributesToFindDeprecatedAttributes($sharepointAttributes, $typo3ListAttributes);
         if (count($deprecatedAttributes) > 0) {
             foreach ($deprecatedAttributes as $deprecatedAttribute) {
                 $this->mappingAttributeRepository->update($deprecatedAttribute);
             }
         }
         // Sync TYPO3 attributes with sharepoint attributes to find out all renamed attributes
         $renamedAttributes = \Aijko\SharepointConnector\Utility\Attribute::syncAttributesToFindRenamedAttributes($sharepointAttributes, $typo3ListAttributes, $this->mappingAttributeRepository);
         if (count($renamedAttributes) > 0) {
             foreach ($renamedAttributes as $renamedAttribute) {
                 $this->mappingAttributeRepository->update($renamedAttribute);
             }
         }
     }
     $this->view->assign('list', $list);
 }
Ejemplo n.º 2
0
 /**
  * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Aijko\SharepointConnector\Domain\Model\Sharepoint\RecordResult> $resultObject
  * @return array
  */
 public function process(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $resultObject)
 {
     $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->mappingListsRepository = $this->objectManager->get('Aijko\\SharepointConnector\\Domain\\Repository\\Mapping\\ListsRepository');
     $this->sharepointListsRepository = $this->objectManager->get('Aijko\\SharepointConnector\\Domain\\Repository\\Sharepoint\\ListsRepository');
     $updateResults = array();
     foreach ($resultObject as $recordResult) {
         $list = $recordResult->getList();
         $listMapping = $this->mappingListsRepository->findByUid($list->getUid());
         foreach ($listMapping->getAttributes() as $attribute) {
             if ('Lookup' != $attribute->getType()) {
                 continue;
             }
             $targetUidFromLookup = $this->getTargetUidFromLookup($attribute->getLookuplist(), clone $resultObject);
             if (!$targetUidFromLookup) {
                 continue;
             }
             $updateResults[] = $this->sharepointListsRepository->updateRecord($list->getSharepointListIdentifier(), $recordResult->getId(), array($attribute->getSharepointFieldName() => $targetUidFromLookup));
         }
     }
     return $updateResults;
 }