1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of gpupo/netshoes-sdk |
5
|
|
|
* Created by Gilmar Pupo <[email protected]> |
6
|
|
|
* For the information of copyright and license you should read the file |
7
|
|
|
* LICENSE which is distributed with this source code. |
8
|
|
|
* Para a informação dos direitos autorais e de licença você deve ler o arquivo |
9
|
|
|
* LICENSE que é distribuído com este código-fonte. |
10
|
|
|
* Para obtener la información de los derechos de autor y la licencia debe leer |
11
|
|
|
* el archivo LICENSE que se distribuye con el código fuente. |
12
|
|
|
* For more information, see <http://www.g1mr.com/>. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Gpupo\NetshoesSdk\Entity; |
16
|
|
|
|
17
|
|
|
use Gpupo\CommonSdk\Entity\EntityInterface; |
18
|
|
|
use Gpupo\CommonSdk\Entity\ManagerAbstract; |
19
|
|
|
use Gpupo\CommonSdk\Entity\ManagerInterface; |
20
|
|
|
|
21
|
|
|
abstract class AbstractManager extends ManagerAbstract implements ManagerInterface |
22
|
|
|
{ |
23
|
5 |
|
protected function fetchDefaultParameters() |
24
|
|
|
{ |
25
|
|
|
return [ |
26
|
5 |
|
'buId' => 'ZT', |
27
|
|
|
'orderStartDate' => null, |
28
|
|
|
]; |
29
|
|
|
} |
30
|
|
|
|
31
|
18 |
|
public function factoryMap($operation, array $parameters = null) |
32
|
|
|
{ |
33
|
18 |
|
return parent::factoryMap($operation, array_merge($this->fetchDefaultParameters(), (array) $parameters)); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @codeCoverageIgnore |
38
|
|
|
* |
39
|
|
|
* @return Gpupo\Common\Entity\CollectionAbstract|null|false |
40
|
|
|
*/ |
41
|
|
|
protected function fetchPrepare($data) |
42
|
|
|
{ |
43
|
|
|
if (empty($data)) { |
44
|
|
|
return false; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
return $this->factoryEntityCollection($data); |
48
|
|
|
} |
49
|
|
|
|
50
|
4 |
|
protected function factoryEntityCollection($data) |
51
|
|
|
{ |
52
|
4 |
|
return $this->factoryNeighborObject($this->getEntityName().'Collection', $data); |
53
|
|
|
} |
54
|
|
|
|
55
|
1 |
|
public function save(EntityInterface $entity, $route = 'save') |
56
|
|
|
{ |
57
|
1 |
|
return $this->execute($this->factoryMap($route), $entity->toJson($route)); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return Gpupo\Common\Entity\CollectionAbstract|false |
62
|
|
|
*/ |
63
|
4 |
|
public function findById($itemId) |
64
|
|
|
{ |
65
|
4 |
|
$data = parent::findById($itemId); |
66
|
|
|
|
67
|
4 |
|
if (empty($data) || $data->get('type') === 'Resource_Not_Found') { |
68
|
1 |
|
return false; |
69
|
|
|
} |
70
|
|
|
|
71
|
3 |
|
return $this->factoryEntity($data->toArray()); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* {@inheritdoc} |
76
|
|
|
* |
77
|
|
|
* @codeCoverageIgnore |
78
|
|
|
*/ |
79
|
|
|
public function update(EntityInterface $entity, EntityInterface $existent = null) |
80
|
|
|
{ |
81
|
|
|
$text = 'Chamada a Atualização de entity '.$this->entity; |
82
|
|
|
|
83
|
|
|
return $this->log('debug', $text, [ |
84
|
|
|
'entity' => $entity, |
85
|
|
|
'existent' => $existent, |
86
|
|
|
]); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|