/**
  * {@inheritdoc}
  */
 public function onChannelSucceedSave(ChannelSaveEvent $event)
 {
     $channel = $event->getChannel();
     if ($channel->getChannelType() === ChannelType::TYPE && $channel->getDataSource()->getTransport() instanceof ZohoRestTransport) {
         $this->transportEntity = $channel->getDataSource()->getTransport();
         parent::onChannelSucceedSave($event);
     }
 }
 protected function prepareEvent()
 {
     $this->entity->setEntities(['OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity1', 'OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity2']);
     $this->event->expects($this->atLeastOnce())->method('getChannel')->will($this->returnValue($this->entity));
     $this->settingProvider->expects($this->at(0))->method('getIntegrationConnectorName')->with('OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity1')->will($this->returnValue('TestConnector1'));
     $this->settingProvider->expects($this->at(1))->method('getIntegrationConnectorName')->with('OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity2')->will($this->returnValue('TestConnector2'));
     $this->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->em));
     $this->em->expects($this->once())->method('persist')->with($this->integration);
     $this->em->expects($this->once())->method('flush');
 }
 public function testOnChannelSucceedSave()
 {
     $this->entity->setEntities(['OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity1', 'OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity2']);
     $this->event->expects($this->once())->method('getChannel')->will($this->returnValue($this->entity));
     $this->settingProvider->expects($this->at(0))->method('getIntegrationConnectorName')->with('OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity1')->will($this->returnValue('TestConnector1'));
     $this->settingProvider->expects($this->at(1))->method('getIntegrationConnectorName')->with('OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity2')->will($this->returnValue('TestConnector2'));
     $this->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->em));
     $this->em->expects($this->once())->method('persist')->with($this->integration);
     $this->em->expects($this->once())->method('flush');
     $channelSaveSucceedListener = new ChannelSaveSucceedListener($this->settingProvider, $this->registry);
     $channelSaveSucceedListener->onChannelSucceedSave($this->event);
     $this->assertEquals($this->integration->getConnectors(), ['TestConnector1', 'TestConnector2']);
 }
 /**
  * @param ChannelSaveEvent $event
  */
 public function onChannelSucceedSave(ChannelSaveEvent $event)
 {
     /** @var Channel $channel */
     $channel = $event->getChannel();
     $dataSource = $channel->getDataSource();
     if ($dataSource instanceof Integration) {
         $entities = $channel->getEntities();
         $connectors = $this->getConnectors($entities);
         $dataSource->setConnectors($connectors);
         $dataSource->setEnabled(Channel::STATUS_ACTIVE === $channel->getStatus());
         $dataSource->setEditMode(Integration::EDIT_MODE_DISALLOW);
         $this->getManager()->persist($dataSource);
         $this->getManager()->flush();
     }
 }
Example #5
0
 public function testGetter()
 {
     $channel = $this->getMock('OroCRM\\Bundle\\ChannelBundle\\Entity\\Channel');
     $event = new ChannelSaveEvent($channel);
     $this->assertSame($channel, $event->getChannel());
 }