Esempio n. 1
0
 /**
  * Returns built channel
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  *
  * @return Channel
  */
 public function getChannel()
 {
     $type = $this->getDefaultType();
     $name = $this->getDefaultName($type);
     $identity = $this->settingsProvider->getCustomerIdentityFromConfig($type);
     if ($this->populateEntities) {
         $this->entities = $this->settingsProvider->getEntitiesByChannelType($type);
     }
     $this->addEntity($identity, true);
     $owner = $this->owner;
     if (!$owner) {
         $owner = $this->getDefaultOrganization();
     }
     $this->channel->setChannelType($type);
     $this->channel->setName($name);
     $this->channel->setOwner($owner);
     $this->channel->setCustomerIdentity($identity);
     $this->channel->setEntities($this->entities);
     $this->channel->setStatus($this->status);
     $this->channel->setDataSource($this->dataSource);
     if (null !== $this->createdAt) {
         // set created at only whn not nullable, otherwise update scenario will fail
         $this->channel->setCreatedAt($this->createdAt);
     }
     return $this->channel;
 }
Esempio n. 2
0
 /**
  * @param string  $key
  * @param Channel $entity
  */
 public function fillEntityData($key, $entity)
 {
     list($name, $type) = explode('|', $key);
     $entity->setName($name);
     $entity->setChannelType($type);
     $entity->setStatus(Channel::STATUS_ACTIVE);
     $entity->setCreatedAt(new \DateTime());
     $entity->setUpdatedAt(new \DateTime());
 }
Esempio n. 3
0
 public function testPostSubmit()
 {
     $data = new Channel();
     $data->setChannelType(self::TEST_CHANNEL_TYPE);
     $form = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface');
     $event = new FormEvent($form, $data);
     $this->subscriber->postSubmit($event);
     $this->assertEquals(self::TEST_CUSTOMER_IDENTITY, $data->getCustomerIdentity());
 }
Esempio n. 4
0
 /**
  * @param Channel $channel
  */
 protected function handleRequestChannelType(Channel &$channel)
 {
     if ($channel->getChannelType()) {
         return;
     }
     $channelType = $this->request->get(sprintf('%s[channelType]', ChannelType::NAME), null, true);
     if (!$channelType) {
         return;
     }
     $channel->setChannelType($channelType);
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $this->em = $manager;
     $date = new \DateTime('now');
     $channel = new Channel();
     $channel->setName('some name');
     $channel->setOwner($this->loadOwner());
     $channel->setChannelType('testType');
     $channel->setCreatedAt($date);
     $channel->setUpdatedAt($date);
     $channel->setCustomerIdentity('test1');
     $channel->setEntities(['test1', 'test2']);
     $manager->persist($channel);
     $this->setReference('default_channel', $channel);
     $manager->flush();
 }
Esempio n. 6
0
 /**
  * Returns built channel
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  *
  * @return Channel
  */
 public function getChannel()
 {
     $type = $this->getDefaultType();
     $name = $this->getDefaultName($type);
     $identity = $this->settingsProvider->getCustomerIdentityFromConfig($type);
     if ($this->populateEntities) {
         $this->entities = $this->settingsProvider->getEntitiesByChannelType($type);
     }
     $this->addEntity($identity, true);
     $owner = $this->owner;
     if (!$owner) {
         $owner = $this->getDefaultOrganization();
     }
     $this->channel->setChannelType($type);
     $this->channel->setName($name);
     $this->channel->setOwner($owner);
     $this->channel->setCustomerIdentity($identity);
     $this->channel->setEntities($this->entities);
     $this->channel->setStatus($this->status);
     $this->channel->setDataSource($this->dataSource);
     return $this->channel;
 }
Esempio n. 7
0
 /**
  * @return array
  */
 public function handleRequestDataProvider()
 {
     $channel = new Channel();
     $channel->setChannelType('existing_type');
     return ['has type' => [$channel, null, 'existing_type'], 'has not request value' => [$channel, null, 'existing_type'], 'has request value' => [new Channel(), 'some_type', 'some_type']];
 }
 public function testIsApplicableVisitEventNonMagentoChannel()
 {
     $this->extendConfigProvider->expects($this->once())->method('hasConfig')->willReturn(true);
     $visitEvent = new TrackingVisitEvent();
     $visit = new TrackingVisit();
     $visitEvent->setVisit($visit);
     $channel = new Channel();
     $channel->setChannelType('test');
     $website = new TestTrackingWebsite();
     $website->setChannel($channel);
     $visit->setTrackingWebsite($website);
     $this->assertFalse($this->provider->isApplicableVisitEvent($visitEvent));
 }