|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of gpupo/netshoes-sdk |
|
5
|
|
|
* Created by Gilmar Pupo <[email protected]> |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
* For more information, see <http://www.g1mr.com/>. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Gpupo\NetshoesSdk\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use Gpupo\CommonSdk\Entity\EntityInterface; |
|
14
|
|
|
use Gpupo\CommonSdk\Entity\ManagerAbstract as CommonAbstract; |
|
15
|
|
|
use Gpupo\CommonSdk\Entity\ManagerInterface; |
|
16
|
|
|
|
|
17
|
|
|
abstract class ManagerAbstract extends CommonAbstract implements ManagerInterface |
|
18
|
|
|
{ |
|
19
|
7 |
|
protected function fetchDefaultParameters() |
|
20
|
|
|
{ |
|
21
|
|
|
return [ |
|
22
|
7 |
|
'buId' => 'ZT', |
|
23
|
|
|
]; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
7 |
|
public function factoryMap($operation, array $parameters = null) |
|
27
|
|
|
{ |
|
28
|
7 |
|
return parent::factoryMap($operation, array_merge($this->fetchDefaultParameters(), $parameters)); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @return Gpupo\Common\Entity\CollectionAbstract|null |
|
33
|
|
|
*/ |
|
34
|
4 |
|
protected function fetchPrepare($data) |
|
35
|
|
|
{ |
|
36
|
4 |
|
if (!empty($data)) { |
|
37
|
4 |
|
return $this->factoryEntityCollection($data); |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
4 |
|
protected function factoryEntityCollection($data) |
|
42
|
|
|
{ |
|
43
|
4 |
|
return $this->factoryNeighborObject($this->getEntityName().'Collection', $data); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @return Gpupo\Common\Entity\CollectionAbstract|null |
|
48
|
|
|
*/ |
|
49
|
3 |
|
public function findById($itemId) |
|
50
|
|
|
{ |
|
51
|
3 |
|
$data = parent::findById($itemId); |
|
52
|
|
|
|
|
53
|
3 |
|
if (!empty($data)) { |
|
54
|
3 |
|
return $this->factoryEntity($data->toArray()); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* {@inheritdoc} |
|
60
|
|
|
*/ |
|
61
|
|
|
public function update(EntityInterface $entity, EntityInterface $existent = null) |
|
62
|
|
|
{ |
|
63
|
|
|
$text = 'Chamada a Atualização de entity '.$this->entity; |
|
64
|
|
|
|
|
65
|
|
|
return $this->log('debug', $text, [ |
|
66
|
|
|
'entity' => $entity, |
|
67
|
|
|
'existent' => $existent, |
|
68
|
|
|
]); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|