Skip to content

Commit 049eff4

Browse files
author
Avikarsha Saha
committed
var in config
1 parent bd0642f commit 049eff4

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

Config/config.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@
868868
'mautic.campaign.model.event',
869869
'event_dispatcher',
870870
'custom_object.helper.token_formatter',
871+
'%mautic.custom_item_fetch_limit_per_lead%',
871872
],
872873
],
873874
'custom_object.segments.decorator_delegate.subscriber' => [
@@ -1189,10 +1190,11 @@
11891190
],
11901191
],
11911192
'parameters' => [
1192-
ConfigProvider::CONFIG_PARAM_ENABLED => true,
1193-
ConfigProvider::CONFIG_PARAM_ITEM_VALUE_TO_CONTACT_RELATION_LIMIT => ConfigProvider::CONFIG_PARAM_ITEM_VALUE_TO_CONTACT_RELATION_DEFAULT_LIMIT,
1194-
'custom_item_export_dir' => '%kernel.root_dir%/../media/files/temp',
1195-
'custom_object_merge_filter' => false,
1193+
ConfigProvider::CONFIG_PARAM_ENABLED => true,
1194+
ConfigProvider::CONFIG_PARAM_ITEM_VALUE_TO_CONTACT_RELATION_LIMIT => ConfigProvider::CONFIG_PARAM_ITEM_VALUE_TO_CONTACT_RELATION_DEFAULT_LIMIT,
1195+
'custom_item_export_dir' => '%kernel.root_dir%/../media/files/temp',
1196+
'custom_object_merge_filter' => false,
1197+
'custom_item_fetch_limit_per_lead' => 15,
11961198
],
11971199
];
11981200

EventListener/TokenSubscriber.php

+19-14
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ class TokenSubscriber implements EventSubscriberInterface
4848
use MatchFilterForLeadTrait;
4949
use QueryBuilderManipulatorTrait;
5050

51-
private const CUSTOM_ITEMS_LIMIT = 15;
52-
5351
/**
5452
* @var ConfigProvider
5553
*/
@@ -100,6 +98,11 @@ class TokenSubscriber implements EventSubscriberInterface
10098
*/
10199
private $tokenFormatter;
102100

101+
/**
102+
* @var int
103+
*/
104+
private $leadCustomItemFetchLimit;
105+
103106
public function __construct(
104107
ConfigProvider $configProvider,
105108
QueryFilterHelper $queryFilterHelper,
@@ -110,18 +113,20 @@ public function __construct(
110113
TokenParser $tokenParser,
111114
EventModel $eventModel,
112115
EventDispatcherInterface $eventDispatcher,
113-
TokenFormatter $tokenFormatter
116+
TokenFormatter $tokenFormatter,
117+
int $leadCustomItemFetchLimit
114118
) {
115-
$this->configProvider = $configProvider;
116-
$this->queryFilterHelper = $queryFilterHelper;
117-
$this->queryFilterFactory = $queryFilterFactory;
118-
$this->customObjectModel = $customObjectModel;
119-
$this->customItemModel = $customItemModel;
120-
$this->customFieldModel = $customFieldModel;
121-
$this->tokenParser = $tokenParser;
122-
$this->eventModel = $eventModel;
123-
$this->eventDispatcher = $eventDispatcher;
124-
$this->tokenFormatter = $tokenFormatter;
119+
$this->configProvider = $configProvider;
120+
$this->queryFilterHelper = $queryFilterHelper;
121+
$this->queryFilterFactory = $queryFilterFactory;
122+
$this->customObjectModel = $customObjectModel;
123+
$this->customItemModel = $customItemModel;
124+
$this->customFieldModel = $customFieldModel;
125+
$this->tokenParser = $tokenParser;
126+
$this->eventModel = $eventModel;
127+
$this->eventDispatcher = $eventDispatcher;
128+
$this->tokenFormatter = $tokenFormatter;
129+
$this->leadCustomItemFetchLimit = $leadCustomItemFetchLimit;
125130
}
126131

127132
/**
@@ -464,7 +469,7 @@ private function getCustomItems(CustomObject $customObject, string $leadId): arr
464469
$orderBy = CustomItem::TABLE_ALIAS.'.id';
465470
$orderDir = 'DESC';
466471

467-
$tableConfig = new TableConfig(self::CUSTOM_ITEMS_LIMIT, 1, $orderBy, $orderDir);
472+
$tableConfig = new TableConfig($this->leadCustomItemFetchLimit, 1, $orderBy, $orderDir);
468473
$tableConfig->addParameter('customObjectId', $customObject->getId());
469474
$tableConfig->addParameter('filterEntityType', 'contact');
470475
$tableConfig->addParameter('filterEntityId', $leadId);

Tests/Unit/EventListener/TokenSubscriberTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ protected function setUp(): void
135135
$this->tokenParser,
136136
$this->eventModel,
137137
$this->eventDispatcher,
138-
$this->tokenFormatter
138+
$this->tokenFormatter,
139+
15
139140
);
140141

141142
$this->builderEvent = $this->createMock(BuilderEvent::class);
@@ -857,7 +858,8 @@ private function constructWithDependencies(): void
857858
$this->tokenParser,
858859
$this->eventModel,
859860
$this->eventDispatcher,
860-
new TokenFormatter()
861+
new TokenFormatter(),
862+
15
861863
);
862864
}
863865
}

0 commit comments

Comments
 (0)