1 | <?php |
||
27 | class CustomerInfoManager implements LoggerAwareInterface |
||
28 | { |
||
29 | use LoggerAwareTrait; |
||
30 | |||
31 | /** @var EntityManager */ |
||
32 | protected $em; |
||
33 | |||
34 | /** @var PropertyAccessor */ |
||
35 | protected $accessor; |
||
36 | |||
37 | /** @var MagentoTransportInterface */ |
||
38 | protected $transport; |
||
39 | |||
40 | /** @var CustomerAddressDataConverter */ |
||
41 | protected $customerAddressDataConverter; |
||
42 | |||
43 | /** @var CustomerAddressStrategy */ |
||
44 | protected $customerAddressStrategy; |
||
45 | |||
46 | /** @var ContextProcessor */ |
||
47 | protected $contextProcessor; |
||
48 | |||
49 | /** @var ConvertAddressToContactAdress */ |
||
50 | protected $convertAddressToContactAdress; |
||
51 | |||
52 | protected $baseAddressProperties = [ |
||
53 | 'label', |
||
54 | 'street', |
||
55 | 'street2', |
||
56 | 'city', |
||
57 | 'postalCode', |
||
58 | 'country', |
||
59 | 'organization', |
||
60 | 'region', |
||
61 | 'regionText', |
||
62 | 'namePrefix', |
||
63 | 'firstName', |
||
64 | 'middleName', |
||
65 | 'lastName', |
||
66 | 'nameSuffix', |
||
67 | 'types' |
||
68 | ]; |
||
69 | |||
70 | /** |
||
71 | * @param EntityManager $em |
||
72 | * @param MagentoTransportInterface $transport |
||
73 | * @param CustomerAddressDataConverter $customerAddressDataConverter |
||
74 | * @param CustomerAddressStrategy $customerAddressStrategy |
||
75 | * @param ContextProcessor $contextProcessor |
||
76 | * @param ConvertAddressToContactAdress $convertAddressToContactAdress |
||
77 | */ |
||
78 | public function __construct( |
||
94 | |||
95 | /** |
||
96 | * @param int[] $integrationIds |
||
97 | * @param int[]|null $customersIds |
||
98 | * @param int $batchSize |
||
99 | */ |
||
100 | public function reSyncData($integrationId, $customersIds = null, $batchSize = 25) |
||
165 | |||
166 | /** |
||
167 | * @param $customersIds |
||
168 | * @param $integrationIds |
||
169 | * |
||
170 | * @return \Oro\Bundle\BatchBundle\ORM\Query\BufferedQueryResultIterator |
||
171 | */ |
||
172 | protected function getCustomerIterator($customersIds, $integrationId) |
||
178 | |||
179 | /** |
||
180 | * @param Address $customerAddress |
||
181 | * @param Contact $contact |
||
182 | * |
||
183 | * @return ContactAddress |
||
184 | */ |
||
185 | protected function createContactAddress(Address $customerAddress, Contact $contact) |
||
194 | |||
195 | /** |
||
196 | * @param ContactAddress $contactAddress |
||
197 | * @param Address $customerAddress |
||
198 | * |
||
199 | * @return ContactAddress |
||
200 | */ |
||
201 | protected function updateContactAddress(ContactAddress $contactAddress, Address $customerAddress) |
||
207 | |||
208 | /** |
||
209 | * @param array $listProperties |
||
210 | * @param $firstEntity |
||
211 | * @param $secondEntity |
||
212 | */ |
||
213 | protected function copyProperties($listProperties, $firstEntity, $secondEntity) |
||
227 | |||
228 | /** |
||
229 | * @param Address $customerAddress |
||
230 | * @param Address $magentoAddress |
||
231 | * |
||
232 | * @return Address |
||
233 | */ |
||
234 | protected function updateAddressByDataFromMagento(Address $customerAddress, Address $magentoAddress) |
||
243 | |||
244 | /** |
||
245 | * @return $this |
||
246 | */ |
||
247 | protected function getContextProcessor() |
||
256 | |||
257 | /** |
||
258 | * @param $context |
||
259 | * |
||
260 | * @return $this |
||
261 | */ |
||
262 | protected function setContext($context) |
||
268 | |||
269 | /** |
||
270 | * @param Customer $customer |
||
271 | * @param $id |
||
272 | * |
||
273 | * @return Address|null |
||
274 | * @throws \Exception |
||
275 | */ |
||
276 | protected function findCustomerAddress(Customer $customer, $id) |
||
295 | |||
296 | /** |
||
297 | * @param array $data |
||
298 | * @param Channel $integration |
||
299 | * |
||
300 | * @return mixed|null |
||
301 | */ |
||
302 | protected function convertDataIntoAddress($data, Channel $integration) |
||
314 | |||
315 | /** |
||
316 | * @param Address $customerAddress |
||
317 | * @param Address $address |
||
318 | * @param Contact $contact |
||
319 | * |
||
320 | * @return ContactAddress |
||
321 | */ |
||
322 | private function handleContactAddress($customerAddress, $address, $contact) |
||
335 | } |
||
336 |
The
EntityManager
might become unusable for example if a transaction is rolled back and it gets closed. Let’s assume that somewhere in your application, or in a third-party library, there is code such as the following:If that code throws an exception and the
EntityManager
is closed. Any other code which depends on the same instance of theEntityManager
during this request will fail.On the other hand, if you instead inject the
ManagerRegistry
, thegetManager()
method guarantees that you will always get a usable manager instance.