/** * 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 FormEvent $event */ public function preSet(FormEvent $event) { $form = $event->getForm(); /** @var Channel $data */ $data = $event->getData(); if ($data === null) { return; } $this->setDefaultValues($data); // builds datasource field $datasourceModifier = $this->getDatasourceModifierClosure($data->getChannelType()); $datasourceModifier($form); $customerIdentity = $this->settingsProvider->getCustomerIdentityFromConfig($data->getChannelType()); $data->setCustomerIdentity($customerIdentity); if (!empty($customerIdentity)) { $this->addEntitiesToChannel($data, [$customerIdentity]); } // pre-fill entities for new instances if (!$data->getId()) { $channelTypeEntities = $this->settingsProvider->getEntitiesByChannelType($data->getChannelType()); $this->addEntitiesToChannel($data, $channelTypeEntities); } }
/** * 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; }