/** * @ TransportInterface $transport */ public function initFromContext() { $this->transport = $this->contextMediator->getTransport($this->getContext(), true); $this->channel = $this->contextMediator->getChannel($this->getContext()); if (!$this->transport) { throw new \InvalidArgumentException('Transport was not provided'); } $this->transport->init($this->channel->getTransport()); }
/** * {@inheritdoc} */ protected function initializeFromContext(ContextInterface $context) { $this->transport = $this->contextMediator->getTransport($context, true); $this->channel = $this->contextMediator->getChannel($context); $this->validateConfiguration(); $this->transport->init($this->channel->getTransport()); $this->setSourceIterator($this->getConnectorSource()); if ($this->getSourceIterator() instanceof LoggerAwareInterface) { $this->getSourceIterator()->setLogger($this->logger); } }
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); }
/** * Configure processor * * @param Channel $channel * * @throws \LogicException */ protected function configure(Channel $channel) { /** @var SoapTransport $transport */ $transport = $this->helper->getTransport($channel); $transport->init($channel->getTransport()); /** @var ParameterBag $settings */ $settings = $channel->getTransport()->getSettingsBag(); if (!$transport->isSupportedExtensionVersion()) { throw new ExtensionRequiredException(); } $websiteId = $settings->get('website_id'); $stores = $this->getSores($transport, $websiteId); if (empty($stores)) { throw new \LogicException(sprintf('Could not resolve store dependency for website id: %d', $websiteId)); } $this->transport = $transport; $this->stores = $stores; }
/** * Configure processor * * @param Channel $channel * * @throws \LogicException */ protected function configure(Channel $channel) { $transport = $this->helper->getTransport($channel); $transport->init($channel->getTransport()); $settings = $channel->getTransport()->getSettingsBag(); if (!$transport->isExtensionInstalled()) { throw new ExtensionRequiredException(); } $websiteId = $settings->get('website_id'); $stores = []; $magentoStores = iterator_to_array($transport->getStores()); foreach ($magentoStores as $store) { if ($store['website_id'] == $websiteId) { $stores[] = $store['store_id']; } } if (empty($stores)) { throw new \LogicException(sprintf('Could not resolve store dependency for website id: %d', $websiteId)); } $this->transport = $transport; $this->stores = $stores; }