3 code examples of PHP Oro\Bundle\ChannelBundle\Entity\Channel extracted from open source projects
protected function handleRequestChannelType(Channel &$channel)
{
if ($channel->getChannelType()) {
return;
}
$formData = $this->requestStack->getCurrentRequest()->get(ChannelType::NAME);
$channelType = $formData['channelType'] ?? null;
if (!$channelType) {
return;
}
$channel->setChannelType($channelType);
}
private function addEntitiesToChannel(Channel $channel, array $entitiesToAdd)
{
$entities = $channel->getEntities();
$entities = is_array($entities) ? $entities : [];
$combinedEntities = array_unique(array_merge($entities, $entitiesToAdd));
$channel->setEntities($combinedEntities);
}
protected function persistDemoRFM(ObjectManager $om, Channel $dataChannel, Organization $organization)
{
$rfmData = [
'recency' => [
['min' => null, 'max' => 7],
['min' => 7, 'max' => 30],
['min' => 30, 'max' => 90],
['min' => 90, 'max' => 365],
['min' => 365, 'max' => null],
],
'frequency' => [
['min' => 52, 'max' => null],
['min' => 12, 'max' => 52],
['min' => 4, 'max' => 12],
['min' => 2, 'max' => 4],
['min' => null, 'max' => 2],
],
'monetary' => [
['min' => 10000, 'max' => null],
['min' => 1000, 'max' => 10000],
['min' => 100, 'max' => 1000],
['min' => 10, 'max' => 100],
['min' => null, 'max' => 10],
],
];
foreach ($rfmData as $type => $values) {
foreach ($values as $idx => $limits) {
$category = new RFMMetricCategory();
$category->setCategoryIndex($idx + 1)
->setChannel($dataChannel)
->setCategoryType($type)
->setMinValue($limits['min'])
->setMaxValue($limits['max'])
->setOwner($organization);
$om->persist($category);
}
}
$data = $dataChannel->getData();
$data['rfm_enabled'] = true;
$dataChannel->setData($data);
$om->persist($dataChannel);
}