|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of gpupo/cnova-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 <https://opensource.gpupo.com/>. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Gpupo\CnovaSdk\Entity; |
|
16
|
|
|
|
|
17
|
|
|
use Gpupo\CommonSdk\Entity\EntityInterface; |
|
18
|
|
|
use Gpupo\CommonSdk\Entity\ManagerAbstract as CommonAbstract; |
|
19
|
|
|
use Gpupo\CommonSdk\Entity\ManagerInterface; |
|
20
|
|
|
|
|
21
|
|
|
abstract class ManagerAbstract extends CommonAbstract implements ManagerInterface |
|
22
|
|
|
{ |
|
23
|
17 |
|
protected function fetchDefaultParameters() |
|
24
|
|
|
{ |
|
25
|
|
|
return [ |
|
26
|
17 |
|
'status' => '', |
|
27
|
|
|
'createdAt' => '', |
|
28
|
|
|
'purchaseAt' => '', |
|
29
|
|
|
]; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @return Gpupo\Common\Entity\CollectionAbstract|null |
|
34
|
|
|
*/ |
|
35
|
17 |
|
protected function fetchPrepare($data) |
|
36
|
|
|
{ |
|
37
|
17 |
|
if (!empty($data)) { |
|
38
|
17 |
|
return $this->factoryEntityCollection($data); |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
17 |
|
protected function factoryEntityCollection($data) |
|
43
|
|
|
{ |
|
44
|
17 |
|
return $this->factoryNeighborObject($this->getEntityName().'Collection', $data); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return Gpupo\Common\Entity\CollectionAbstract|null |
|
49
|
|
|
*/ |
|
50
|
4 |
|
public function findById($itemId) |
|
51
|
|
|
{ |
|
52
|
4 |
|
$data = parent::findById($itemId); |
|
53
|
|
|
|
|
54
|
4 |
|
if (!empty($data)) { |
|
55
|
4 |
|
return $this->factoryEntity($data->toArray()); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* {@inheritdoc} |
|
61
|
|
|
*/ |
|
62
|
3 |
|
public function update(EntityInterface $entity, EntityInterface $existent) |
|
63
|
|
|
{ |
|
64
|
3 |
|
$text = 'Chamada a Atualização de entity '.$this->entity; |
|
65
|
|
|
|
|
66
|
3 |
|
return $this->log('debug', $text, [ |
|
67
|
3 |
|
'entity' => $entity, |
|
68
|
3 |
|
'existent' => $existent, |
|
69
|
|
|
]); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|