/** * 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; }
/** * @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()); }
/** * @dataProvider dataProvider */ public function testOnChannelStatusChange($status, $isEnabled) { $integration = new Integration(); $entity = new Channel(); $entity->setStatus($status); $entity->setDataSource($integration); $this->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->em)); $this->em->expects($this->once())->method('persist')->with($integration); $this->em->expects($this->once())->method('flush'); $listener = new ChangeChannelStatusListener($this->registry); $listener->onChannelStatusChange(new ChannelChangeStatusEvent($entity)); $this->assertEquals($integration->getEnabled(), $isEnabled); }
/** * 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; }
/** * @Route( * "/status/change/{id}", * requirements={"id"="\d+"}, * name="orocrm_channel_change_status" * ) * @AclAncestor("orocrm_channel_update") */ public function changeStatusAction(Channel $channel) { if ($channel->getStatus() == Channel::STATUS_ACTIVE) { $message = 'orocrm.channel.controller.message.status.deactivated'; $channel->setStatus(Channel::STATUS_INACTIVE); } else { $message = 'orocrm.channel.controller.message.status.activated'; $channel->setStatus(Channel::STATUS_ACTIVE); } $this->getDoctrine()->getManager()->flush(); $event = new ChannelChangeStatusEvent($channel); $this->get('event_dispatcher')->dispatch(ChannelChangeStatusEvent::EVENT_NAME, $event); $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans($message)); return $this->redirect($this->generateUrl('orocrm_channel_view', ['id' => $channel->getId(), '_enableContentProviders' => 'mainMenu'])); }