Exemplo n.º 1
0
 protected function getImportProcessorsChoices($entityName)
 {
     $aliases = $this->processorRegistry->getProcessorAliasesByEntity(ProcessorRegistry::TYPE_IMPORT, $entityName);
     $result = array();
     foreach ($aliases as $alias) {
         $result[$alias] = $this->generateProcessorLabel($alias);
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Process channel synchronization
  *
  * @param Integration $integration Integration object
  * @param string      $connector   Connector name
  * @param array       $parameters  Connector additional parameters
  *
  * @return $this
  */
 public function process(Integration $integration, $connector, array $parameters)
 {
     if (!$integration->getEnabled()) {
         return $this;
     }
     try {
         $this->logger->info(sprintf('Start processing "%s" connector', $connector));
         $realConnector = $this->getRealConnector($integration, $connector);
         if (!$realConnector instanceof TwoWaySyncConnectorInterface) {
             throw new LogicException('This connector doesn`t support two-way sync.');
         }
     } catch (\Exception $e) {
         return $this->logger->error($e->getMessage());
     }
     $processorAliases = $this->processorRegistry->getProcessorAliasesByEntity(ProcessorRegistry::TYPE_EXPORT, $realConnector->getImportEntityFQCN());
     $configuration = [ProcessorRegistry::TYPE_EXPORT => array_merge(['entityName' => $realConnector->getImportEntityFQCN(), 'processorAlias' => reset($processorAliases), 'channel' => $integration->getId()], $parameters)];
     $this->processExport($realConnector->getExportJobName(), $configuration);
     return $this;
 }
Exemplo n.º 3
0
 public function testGetProcessorAliasesByEntity()
 {
     $type = ProcessorRegistry::TYPE_IMPORT;
     $entityName = 'entity_name';
     $fooAlias = 'foo_alias';
     $fooProcessor = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Processor\\ProcessorInterface');
     $barAlias = 'bar_alias';
     $barProcessor = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Processor\\ProcessorInterface');
     $this->registry->registerProcessor($fooProcessor, $type, $entityName, $fooAlias);
     $this->registry->registerProcessor($barProcessor, $type, $entityName, $barAlias);
     $this->assertEquals([$fooAlias, $barAlias], $this->registry->getProcessorAliasesByEntity($type, $entityName));
 }
Exemplo n.º 4
0
 /**
  * Process integration connector
  *
  * @param Integration $integration Integration object
  * @param string      $connector   Connector name
  * @param array       $parameters  Connector additional parameters
  * @param boolean     $saveStatus  Do we need to save new status to bd
  *
  * @return boolean
  */
 protected function processIntegrationConnector(Integration $integration, $connector, array $parameters = [], $saveStatus = true)
 {
     if (!$integration->getEnabled()) {
         return false;
     }
     try {
         $this->logger->info(sprintf('Start processing "%s" connector', $connector));
         // Clone object here because it will be modified and changes should not be shared between
         $realConnector = clone $this->registry->getConnectorType($integration->getType(), $connector);
         $jobName = $realConnector->getImportJobName();
         $processorAliases = $this->processorRegistry->getProcessorAliasesByEntity(ProcessorRegistry::TYPE_IMPORT, $realConnector->getImportEntityFQCN());
     } catch (\Exception $e) {
         // log and continue
         $this->logger->error($e->getMessage());
         $status = new Status();
         $status->setCode(Status::STATUS_FAILED)->setMessage($e->getMessage())->setConnector($connector);
         $this->doctrineRegistry->getRepository('OroIntegrationBundle:Channel')->addStatus($integration, $status);
         return false;
     }
     $configuration = [ProcessorRegistry::TYPE_IMPORT => array_merge(['processorAlias' => reset($processorAliases), 'entityName' => $realConnector->getImportEntityFQCN(), 'channel' => $integration->getId(), 'channelType' => $integration->getType()], $parameters)];
     return $this->processImport($connector, $jobName, $configuration, $integration, $saveStatus);
 }