/
ConfigInterface.php
193 lines (172 loc) · 5.53 KB
/
ConfigInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
declare(strict_types=1);
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/
namespace Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config\Definition\Attribute;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Worker\WorkerInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\Model\IndexableInterface;
use Pimcore\Model\DataObject;
/**
* Interface for IndexService Tenant Configurations
*/
interface ConfigInterface
{
/**
* returns tenant name
*
* @return string
*/
public function getTenantName(): string;
/**
* Returns configured attributes for product index
*
* @return Attribute[]
*/
public function getAttributes(): array;
/**
* Returns full text search index attribute names for product index
*
* @return array
*/
public function getSearchAttributes(): array;
/**
* return all supported filter types for product index
*
* @return array|null
*/
public function getFilterTypeConfig(): ?array;
/**
* returns if given product is active for this tenant
*
* @param IndexableInterface $object
*
* @return bool
*/
public function isActive(IndexableInterface $object): bool;
/**
* checks, if product should be in index for current tenant
*
* @param IndexableInterface $object
*
* @return bool
*/
public function inIndex(IndexableInterface $object): bool;
/**
* Returns categories for given object in context of the current tenant.
* Possible hook to filter categories for specific tenants.
*
* @param IndexableInterface $object
* @param int|null $subObjectId
*
* @return \Pimcore\Bundle\EcommerceFrameworkBundle\Model\AbstractCategory[]
*/
public function getCategories(IndexableInterface $object, int $subObjectId = null): array;
/**
* in case of subtenants returns a data structure containing all sub tenants
*
* @param IndexableInterface $object
* @param int|null $subObjectId
*
* @return mixed $subTenantData
*/
public function prepareSubTenantEntries(IndexableInterface $object, int $subObjectId = null): mixed;
/**
* populates index for tenant relations based on given data
*
* @param mixed $objectId
* @param mixed $subTenantData
* @param mixed $subObjectId
*
* @return void
*/
public function updateSubTenantEntries(mixed $objectId, mixed $subTenantData, mixed $subObjectId = null): void;
/**
* Config <-> worker have a 1:1 relation as the config
* needs to access its worker in certain cases.
*
* @param WorkerInterface $tenantWorker
*
* @throws \LogicException If the config already has a worker set
* @throws \LogicException If the config used from the worker does not match the config object the worker is
* about to be set to
*/
public function setTenantWorker(WorkerInterface $tenantWorker): void;
/**
* creates and returns tenant worker suitable for this tenant configuration
*
* @return WorkerInterface
*/
public function getTenantWorker(): WorkerInterface;
/**
* creates an array of sub ids for the given object
* use that function, if one object should be indexed more than once (e.g. if field collections are in use)
*
* @param IndexableInterface $object
*
* @return IndexableInterface[]
*/
public function createSubIdsForObject(IndexableInterface $object): array;
/**
* checks if there are some zombie subIds around and returns them for cleanup
*
* @param IndexableInterface $object
* @param array $subIds
*
* @return array
*/
public function getSubIdsToCleanup(IndexableInterface $object, array $subIds): array;
/**
* creates virtual parent id for given sub id
* default is getOSParentId
*
* @param IndexableInterface $object
* @param int $subId
*
* @return mixed
*/
public function createVirtualParentIdForSubId(IndexableInterface $object, int $subId): mixed;
/**
* Gets object by id, can consider subIds and therefore return e.g. an array of values
* always returns object itself - see also getObjectMockupById
*
* @param int $objectId
* @param bool $onlyMainObject - only returns main object
*
* @return DataObject|null
*/
public function getObjectById(int $objectId, bool $onlyMainObject = false): ?DataObject;
/**
* Gets object mockup by id, can consider subIds and therefore return e.g. an array of values
* always returns a object mockup if available
*
* @param int $objectId
*
* @return IndexableInterface|null
*/
public function getObjectMockupById(int $objectId): ?IndexableInterface;
/**
* returns column type for id
*
* @param bool $isPrimary
*
* @return string
*/
public function getIdColumnType(bool $isPrimary): string;
/**
* Attribute configuration
*
* @return array
*/
public function getAttributeConfig(): array;
}