Esempio n. 1
0
 /**
  * Checks whether integration has at least on connector that supports backward sync
  *
  * @param string $integrationType
  *
  * @return bool
  */
 public function hasTwoWaySyncConnectors($integrationType)
 {
     $connectors = $this->registry->getRegisteredConnectorsTypes($integrationType, function (ConnectorInterface $connector) {
         return $connector instanceof TwoWaySyncConnectorInterface;
     });
     return !$connectors->isEmpty();
 }
Esempio n. 2
0
 protected function getExtensions()
 {
     $assetsHelper = $this->getMockBuilder('Symfony\\Component\\Templating\\Helper\\CoreAssetsHelper')->disableOriginalConstructor()->getMock();
     $integrationType = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Provider\\ChannelInterface');
     $transportType = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Provider\\TransportInterface');
     $registry = new TypesRegistry();
     $registry->addChannelType(self::TEST_TYPE, $integrationType);
     $registry->addTransportType(uniqid('transport'), self::TEST_TYPE, $transportType);
     $security = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock();
     $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $metadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
     $em->expects($this->once())->method('getClassMetadata')->with($this->equalTo('OroUser:User'))->will($this->returnValue($metadata));
     $metadata->expects($this->once())->method('getSingleIdentifierFieldName')->will($this->returnValue(self::TEST_ID_FIELD_NAME));
     $searchHandler = $this->getMock('Oro\\Bundle\\FormBundle\\Autocomplete\\SearchHandlerInterface');
     $searchHandler->expects($this->any())->method('getEntityName')->will($this->returnValue('OroUser:User'));
     $searchRegistry = new SearchRegistry();
     $searchRegistry->addSearchHandler('acl_users', $searchHandler);
     $config = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $config->expects($this->any())->method('has')->with($this->equalTo('grid_name'))->will($this->returnValue(true));
     $config->expects($this->any())->method('get')->with($this->equalTo('grid_name'))->will($this->returnValue('test_grid'));
     $cp = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProviderInterface');
     $cp->expects($this->any())->method('getConfig')->will($this->returnValue($config));
     $cm = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigManager')->disableOriginalConstructor()->getMock();
     $cm->expects($this->any())->method('getProvider')->will($this->returnValue($cp));
     $validator = new Validator(new ClassMetadataFactory(new LoaderChain([])), new ConstraintValidatorFactory(), new DefaultTranslator());
     $settingsProvider = $this->getMockBuilder('OroCRM\\Bundle\\ChannelBundle\\Provider\\SettingsProvider')->disableOriginalConstructor()->getMock();
     return [new PreloadedExtension(['oro_integration_channel_form' => $this->getChannelType($registry), 'oro_integration_type_select' => new IntegrationTypeSelectType($registry, $assetsHelper), 'oro_user_organization_acl_select' => new OrganizationUserAclSelectType(), 'oro_user_acl_select' => new UserAclSelectType(), 'oro_entity_create_or_select_inline' => new OroEntitySelectOrCreateInlineType($security, $cm), 'oro_jqueryselect2_hidden' => new OroJquerySelect2HiddenType($em, $searchRegistry, $cp), 'genemu_jqueryselect2_choice' => new Select2Type('choice'), 'genemu_jqueryselect2_hidden' => new Select2Type('hidden')], ['form' => [new FormTypeCsrfExtension($this->getMock('Symfony\\Component\\Form\\Extension\\Csrf\\CsrfProvider\\CsrfProviderInterface')), new FormTypeValidatorExtension($validator), new TooltipFormExtension()], 'oro_integration_channel_form' => [new IntegrationTypeExtension($settingsProvider)]])];
 }
 /**
  * Returns a list of available integration types
  *
  * @return array [{integration type} => [{attr1} => {val1}, ...], ...]
  */
 protected function getAvailableIntegrationTypes()
 {
     if (null === $this->itemsCache) {
         $this->itemsCache = $this->registry->getAvailableIntegrationTypesDetailedData();
     }
     return $this->itemsCache;
 }
Esempio n. 4
0
 public function testSchedule()
 {
     $testIntegrationType = 'testIntegrationType';
     $testConnectorType = 'testConnectorType';
     $testId = 22;
     $integration = new Integration();
     $integration->setType($testIntegrationType);
     $integration->setEnabled(true);
     $ref = new \ReflectionProperty(get_class($integration), 'id');
     $ref->setAccessible(true);
     $ref->setValue($integration, $testId);
     $this->typesRegistry->addChannelType($testIntegrationType, new TestIntegrationType());
     $this->typesRegistry->addConnectorType($testConnectorType, $testIntegrationType, new TestTwoWayConnector());
     $that = $this;
     $uow = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock();
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($uow));
     $metadataFactory = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadataFactory')->disableOriginalConstructor()->getMock();
     $metadataFactory->expects($this->once())->method('getMetadataFor')->will($this->returnValue(new ClassMetadata('testEntity')));
     $this->em->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory));
     $uow->expects($this->once())->method('persist')->with($this->isInstanceOf('JMS\\JobQueueBundle\\Entity\\Job'))->will($this->returnCallback(function (Job $job) use($that, $testId, $testConnectorType) {
         $expectedArgs = ['--integration=' . $testId, sprintf('--connector=testConnectorType', $testConnectorType), '--params=a:0:{}'];
         $that->assertEquals($expectedArgs, $job->getArgs());
     }));
     $uow->expects($this->once())->method('computeChangeSet');
     $this->scheduler->schedule($integration, $testConnectorType, [], false);
 }
 /**
  * {@inheritdoc}
  */
 protected function getConnectors(array $entities)
 {
     $dictionaryConnectors = $this->typeRegistry->getRegisteredConnectorsTypes(ChannelType::TYPE, function (ConnectorInterface $connector) {
         return $connector instanceof DictionaryConnectorInterface;
     })->toArray();
     $connectors = [];
     $initialConnectors = [];
     $isSupportedExtensionVersion = $this->transportEntity->isSupportedExtensionVersion();
     $isExtensionInstalled = $this->transportEntity->getIsExtensionInstalled();
     foreach ($entities as $entity) {
         $connectorName = $this->settingsProvider->getIntegrationConnectorName($entity);
         if ($connectorName) {
             $connector = $this->typeRegistry->getConnectorType(ChannelType::TYPE, $connectorName);
             if (!$connector) {
                 continue;
             }
             $isExtensionApplicable = $connector instanceof ExtensionVersionAwareInterface ? $isSupportedExtensionVersion : $isExtensionInstalled;
             if ($isExtensionApplicable || !$isExtensionApplicable && !$connector instanceof ExtensionAwareInterface) {
                 array_push($initialConnectors, $connectorName . InitialSyncProcessor::INITIAL_CONNECTOR_SUFFIX);
                 array_push($connectors, $connectorName);
             }
         }
     }
     return array_merge(array_keys($dictionaryConnectors), $initialConnectors, $connectors);
 }
Esempio n. 6
0
 /**
  * @param BuildBefore $event
  */
 public function statusGridBuildBefore(BuildBefore $event)
 {
     $params = $event->getDatagrid()->getParameters();
     if ($params->has('integrationType')) {
         $type = $params->get('integrationType');
         $connectorChoices = $this->typesRegistry->getAvailableConnectorsTypesChoiceList($type);
         $event->getDatagrid()->getConfig()->offsetSetByPath('[filters][columns][connector][options][field_options][choices]', $connectorChoices);
     }
 }
 public function testSetDefaultOptions()
 {
     /** @var OptionsResolverInterface|\PHPUnit_Framework_MockObject_MockObject $resolver */
     $resolver = $this->getMock('Symfony\\Component\\OptionsResolver\\OptionsResolverInterface');
     $resolver->expects($this->once())->method('setDefaults')->with($this->isType('array'));
     $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ["label" => "oro.type1.label", "icon" => "bundles/acmedemo/img/logo.png"], 'testType2' => ["label" => "oro.type2.label"]]));
     $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0));
     $this->type->setDefaultOptions($resolver);
 }
 /**
  * Picks proper default owner field for form, based on type.
  *
  * @param FormInterface $form
  * @param string        $type
  */
 protected function setDefaultOwnerField(FormInterface $form, $type = null)
 {
     $type = $this->typesRegistry->getDefaultOwnerType($type);
     if ($type === DefaultOwnerTypeAwareInterface::BUSINESS_UNIT) {
         $this->addBusinessUnitField($form);
     } else {
         $this->addUserOwnerField($form);
     }
 }
Esempio n. 9
0
 public function testHasTwoWaySyncConnectors()
 {
     $testType = 'type2';
     $testTypeThatHasConnectors = 'type1';
     $this->typesRegistry->addChannelType($testType, new TestIntegrationType());
     $this->typesRegistry->addChannelType($testTypeThatHasConnectors, new TestIntegrationType());
     $this->typesRegistry->addConnectorType(uniqid('type'), $testType, new TestConnector());
     $this->typesRegistry->addConnectorType(uniqid('type'), $testTypeThatHasConnectors, new TestTwoWayConnector());
     $this->assertTrue($this->utils->hasTwoWaySyncConnectors($testTypeThatHasConnectors));
     $this->assertFalse($this->utils->hasTwoWaySyncConnectors($testType));
 }
Esempio n. 10
0
 /**
  * @expectedException \LogicException
  * @expectedExceptionMessage Unable to schedule job for "testConnectorType" connector type
  */
 public function testScheduleConnectorError()
 {
     $testIntegrationType = 'testIntegrationType';
     $testConnectorType = 'testConnectorType';
     $integration = new Integration();
     $integration->setType($testIntegrationType);
     $this->typesRegistry->addChannelType($testIntegrationType, new TestIntegrationType());
     $this->typesRegistry->addConnectorType($testConnectorType, $testIntegrationType, new TestConnector());
     $integration->setEnabled(true);
     $this->scheduler->schedule($integration, $testConnectorType);
 }
 /**
  * @return array
  */
 protected function getChoices()
 {
     $choices = [];
     $choicesData = $this->registry->getAvailableIntegrationTypesDetailedData();
     foreach ($choicesData as $typeName => $data) {
         $attributes = [];
         if (!empty($data['icon'])) {
             $attributes['data-icon'] = $this->assetHelper->getUrl($data['icon']);
         }
         $choices[$typeName] = new ChoiceListItem($data['label'], $attributes);
     }
     return $choices;
 }
 public function testGetTransportFromContext()
 {
     $testID = 1;
     $testTransport = new \stdClass();
     $integration = new Integration();
     $integration->setTransport($this->getMockForAbstractClass('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport'));
     $context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface');
     $context->expects($this->once())->method('getOption')->with('channel')->will($this->returnValue($testID));
     $this->repo->expects($this->once())->method('getOrLoadById')->with($testID)->will($this->returnValue($integration));
     $this->registry->expects($this->once())->method('getTransportTypeBySettingEntity')->will($this->returnValue($testTransport));
     $result = $this->contextMediator->getTransport($context);
     $this->assertEquals($testTransport, $result);
 }
Esempio n. 13
0
 /**
  * {@inheritdoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     $typeData = $this->typesRegistry->getAvailableIntegrationTypesDetailedData();
     /** @var ChoiceView $choiceView */
     foreach ($view->vars['choices'] as $choiceView) {
         /** @var Integration $integration */
         $integration = $choiceView->data;
         $attributes = ['data-status' => $integration->isEnabled()];
         if (isset($typeData[$integration->getType()], $typeData[$integration->getType()]['icon'])) {
             $attributes['data-icon'] = $this->assetHelper->getUrl($typeData[$integration->getType()]['icon']);
         }
         $choiceView->label = new ChoiceListItem($choiceView->label, $attributes);
     }
 }
 public function testSetDefaultOptions()
 {
     $resolver = new OptionsResolver();
     $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ['label' => 'oro.type1.label', 'icon' => 'bundles/acmedemo/img/logo.png'], 'testType2' => ['label' => 'oro.type2.label']]));
     $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0));
     $this->type->setDefaultOptions($resolver);
     $result = $resolver->resolve([]);
     $choiceAttr = [];
     foreach ($result['choices'] as $choice => $label) {
         $choiceAttr[$choice] = call_user_func($result['choice_attr'], $choice);
     }
     unset($result['choice_attr']);
     $this->assertEquals(['empty_value' => '', 'choices' => ['testType1' => 'oro.type1.label', 'testType2' => 'oro.type2.label'], 'configs' => ['placeholder' => 'oro.form.choose_value', 'result_template_twig' => 'OroIntegrationBundle:Autocomplete:type/result.html.twig', 'selection_template_twig' => 'OroIntegrationBundle:Autocomplete:type/selection.html.twig']], $result);
     $this->assertEquals(['testType1' => ['data-icon' => 'bundles/acmedemo/img/logo.png'], 'testType2' => []], $choiceAttr);
 }
 public function testFinishView()
 {
     $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ["label" => "oro.type1.label", "icon" => "bundles/acmedemo/img/logo.png"], 'testType2' => ["label" => "oro.type2.label"]]));
     $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0));
     $testIntegration1 = new Integration();
     $testIntegration1->setType('testType1');
     $testIntegration1Label = uniqid('label');
     $testIntegration1Id = uniqid('id');
     $testIntegration2 = new Integration();
     $testIntegration2->setType('testType2');
     $testIntegration2Label = uniqid('label');
     $testIntegration2Id = uniqid('id');
     $view = new FormView();
     $view->vars['choices'] = [new ChoiceView($testIntegration1, $testIntegration1Id, $testIntegration1Label), new ChoiceView($testIntegration2, $testIntegration2Id, $testIntegration2Label)];
     $this->type->finishView($view, $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface'), []);
     $this->assertEquals($testIntegration1Label, $view->vars['choices'][0]->label);
     $this->assertEquals($testIntegration2Label, $view->vars['choices'][1]->label);
     $this->assertEquals(['data-status' => true, 'data-icon' => 'bundles/acmedemo/img/logo.png'], $view->vars['choices'][0]->attr);
 }
 public function testOnChannelSucceedSave()
 {
     $this->entity->setChannelType(ChannelType::TYPE);
     $transport = new MagentoSoapTransport();
     $transport->setIsExtensionInstalled(false);
     $this->integration->setTransport($transport);
     $this->typesRegistry->expects($this->any())->method('getRegisteredConnectorsTypes')->willReturn(new ArrayCollection([]));
     $this->prepareEvent();
     $this->getListener()->onChannelSucceedSave($this->event);
 }
 /**
  * @param array         $data
  * @param FormInterface $form
  */
 protected function modify($data, FormInterface $form)
 {
     if ($this->hasChannelParent($form)) {
         $connectors = $form->getParent()->get('connectors');
         if ($connectors) {
             $config = $connectors->getConfig()->getOptions();
             unset($config['choice_list']);
             unset($config['choices']);
         } else {
             $config = [];
         }
         if (array_key_exists('auto_initialize', $config)) {
             $config['auto_initialize'] = false;
         }
         $allowedTypesChoices = $this->typeRegistry->getAvailableConnectorsTypesChoiceList('magento', function (ConnectorInterface $connector) use($data) {
             return $connector instanceof ExtensionAwareInterface ? $data : true;
         });
         $form->getParent()->add('connectors', 'choice', array_merge($config, ['choices' => $allowedTypesChoices]));
     }
 }
 public function testPreSetWithBusinessUnitDefaultOwnerTypeAndExistingSameField()
 {
     $integration = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Entity\\Channel');
     $integration->expects($this->any())->method('getType')->will($this->returnValue('integration_type'));
     $this->typesRegistry->expects($this->any())->method('getDefaultOwnerType')->with($this->equalTo('integration_type'))->will($this->returnValue(DefaultOwnerTypeAwareInterface::BUSINESS_UNIT));
     $form = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface');
     $form->expects($this->at(0))->method('has')->with($this->equalTo('defaultUserOwner'))->will($this->returnValue(false));
     $form->expects($this->at(1))->method('has')->with($this->equalTo('defaultBusinessUnitOwner'))->will($this->returnValue(true));
     $form->expects($this->never())->method('add');
     $event = new FormEvent($form, $integration);
     $this->subscriber->preSet($event);
 }
Esempio n. 19
0
 /**
  * Schedules backward sync job
  *
  * @param Integration $integration
  * @param string      $connectorType
  * @param array       $params
  * @param bool        $useFlush
  *
  * @throws LogicException
  */
 public function schedule(Integration $integration, $connectorType, $params = [], $useFlush = true)
 {
     if (!$integration->getEnabled()) {
         return;
     }
     $connector = $this->typesRegistry->getConnectorType($integration->getType(), $connectorType);
     if (!$connector instanceof TwoWaySyncConnectorInterface) {
         throw new LogicException(sprintf('Unable to schedule job for "%s" connector type', $connectorType));
     }
     $args = ['--integration=' . $integration->getId(), '--connector=' . $connectorType, '--params=' . serialize($params)];
     $job = new Job(self::JOB_NAME, $args);
     if ($useFlush) {
         $this->em->persist($job);
         $this->em->flush();
     } else {
         $uow = $this->em->getUnitOfWork();
         $uow->persist($job);
         $jobMeta = $this->em->getMetadataFactory()->getMetadataFor('JMS\\JobQueueBundle\\Entity\\Job');
         $uow->computeChangeSet($jobMeta, $job);
     }
 }
 public function testGetInitializedTransport()
 {
     $testTransport = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Provider\\TransportInterface');
     $transportEntity = $this->getMockForAbstractClass('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport');
     $integration = new Integration();
     $integration->setTransport($transportEntity);
     $this->registry->expects($this->once())->method('getTransportTypeBySettingEntity')->will($this->returnValue($testTransport));
     $testTransport->expects($this->once())->method('init')->with($transportEntity);
     $result = $this->contextMediator->getInitializedTransport($integration);
     $this->assertEquals($testTransport, $result);
     // test local cache
     $this->contextMediator->getInitializedTransport($integration);
 }
Esempio n. 21
0
 /**
  * Schedules backward sync job
  *
  * @param Integration $integration
  * @param string      $connectorType
  * @param array       $params
  * @param bool        $useFlush
  *
  * @throws LogicException
  */
 public function schedule(Integration $integration, $connectorType, $params = [], $useFlush = true)
 {
     if (!$integration->isEnabled()) {
         return;
     }
     $connector = $this->typesRegistry->getConnectorType($integration->getType(), $connectorType);
     if (!$connector instanceof TwoWaySyncConnectorInterface) {
         throw new LogicException(sprintf('Unable to schedule job for "%s" connector type', $connectorType));
     }
     $args = ['--integration=' . $integration->getId(), '--connector=' . $connectorType, '--params=' . serialize($params)];
     if (!$this->isScheduled($args)) {
         $job = new Job(self::JOB_NAME, $args);
         /** @var EntityManager $em */
         $em = $this->registry->getManagerForClass('JMSJobQueueBundle:Job');
         $em->persist($job);
         if (true === $useFlush) {
             $em->flush();
         } else {
             $jobMeta = $em->getClassMetadata('JMSJobQueueBundle:Job');
             $em->getUnitOfWork()->computeChangeSet($jobMeta, $job);
         }
     }
 }
Esempio n. 22
0
 /**
  * @param array $connectors
  * @param \DateTime $syncStartDate
  * @param object|null $realConnector
  * @return Channel|\PHPUnit_Framework_MockObject_MockObject
  */
 protected function getIntegration(array $connectors = [], \DateTime $syncStartDate = null, $realConnector = null)
 {
     $integration = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Entity\\Channel')->disableOriginalConstructor()->getMock();
     $integration->expects($this->any())->method('getConnectors')->will($this->returnValue($connectors));
     $integration->expects($this->any())->method('getId')->will($this->returnValue('testChannel'));
     $integration->expects($this->any())->method('getType')->will($this->returnValue('testChannelType'));
     $transport = new MagentoSoapTransport();
     if ($syncStartDate) {
         $transport->setSyncStartDate($syncStartDate);
     }
     $integration->expects($this->any())->method('getTransport')->will($this->returnValue($transport));
     $integration->expects($this->any())->method('isEnabled')->will($this->returnValue(true));
     if (!$realConnector) {
         $realConnector = new TestConnector();
     }
     $this->typesRegistry->expects($this->any())->method('getConnectorType')->will($this->returnValue($realConnector));
     return $integration;
 }
Esempio n. 23
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);
 }
Esempio n. 24
0
 /**
  * Modifies form based on submitted data
  *
  * @param FormEvent $event
  */
 public function preSubmit(FormEvent $event)
 {
     $form = $event->getForm();
     /** @var Integration $originalData */
     $originalData = $form->getData();
     $data = $event->getData();
     $this->muteFields($form, $originalData);
     if (!empty($data['type'])) {
         $type = $data['type'];
         $transportTypeModifier = $this->getTransportTypeModifierClosure($type);
         $transportTypeModifier($form);
         $connectorsModifier = $this->getConnectorsModifierClosure($type);
         $connectorsModifier($form);
         $synchronizationSettingsModifier = $this->getDynamicModifierClosure($type, 'synchronization_settings');
         $synchronizationSettingsModifier($form);
         $mappingSettingsModifier = $this->getDynamicModifierClosure($type, 'mapping_settings');
         $mappingSettingsModifier($form);
         // value that was set on postSet is replaced by null from request
         $typeChoices = array_keys($form->get('transportType')->getConfig()->getOption('choices'));
         $firstChoice = reset($typeChoices);
         $data['transportType'] = isset($data['transportType']) ? $data['transportType'] : $firstChoice;
         /*
          * If transport type changed we have to modify ViewData(it's already saved entity)
          * due to it's not matched the 'data_class' option of newly added form type
          */
         if ($originalData !== null && ($transport = $originalData->getTransport())) {
             $transportType = $this->registry->getTransportTypeBySettingEntity($transport, $originalData->getType(), true);
             // second condition cover case when we have same name for few integration types
             if ($transportType !== $data['transportType'] || $originalData->getType() !== $data['type']) {
                 /** @var Integration $setEntity */
                 $setEntity = $form->getViewData();
                 $setEntity->clearTransport();
             }
         }
         $transportModifier = $this->getTransportModifierClosure($type, $data['transportType']);
         $transportModifier($form);
         $event->setData($data);
     }
 }
Esempio n. 25
0
 public function testGetRegisteredTransportTypes()
 {
     $this->assertInstanceOf('Doctrine\\Common\\Collections\\Collection', $this->typesRegistry->getRegisteredTransportTypes(self::CHANNEL_TYPE_ONE));
 }
Esempio n. 26
0
 /**
  * Clone object here because it will be modified and changes should not be shared between
  *
  * @param Integration $integration
  * @param string      $connector
  *
  * @return TwoWaySyncConnectorInterface
  */
 protected function getRealConnector(Integration $integration, $connector)
 {
     return clone $this->registry->getConnectorType($integration->getType(), $connector);
 }