|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Entity Class |
|
6
|
|
|
* @package Ticaje_Persistence |
|
7
|
|
|
* @author Hector Luis Barrientos <[email protected]> |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Ticaje\Persistence\Entity; |
|
11
|
|
|
|
|
12
|
|
|
use Magento\Framework\Model\AbstractModel; |
|
13
|
|
|
use Magento\Framework\DataObject\IdentityInterface; |
|
14
|
|
|
use Magento\Framework\Model\ResourceModel\AbstractResource; |
|
15
|
|
|
use Magento\Framework\Registry; |
|
16
|
|
|
use Magento\Framework\Data\Collection\AbstractDb; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class Base |
|
20
|
|
|
* @package Ticaje\Persistence\Entity |
|
21
|
|
|
*/ |
|
22
|
|
|
class Base extends AbstractModel implements IdentityInterface |
|
23
|
|
|
{ |
|
24
|
|
|
private $resourceModelClass; |
|
25
|
|
|
|
|
26
|
|
|
private $cacheTag; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Base constructor. |
|
30
|
|
|
* @param Context $context |
|
31
|
|
|
* @param Registry $registry |
|
32
|
|
|
* @param AbstractResource|null $resource |
|
33
|
|
|
* @param AbstractDb|null $resourceCollection |
|
34
|
|
|
* @param string $resourceModelClass |
|
35
|
|
|
* @param string $cacheTag |
|
36
|
|
|
* @param array $data |
|
37
|
|
|
*/ |
|
38
|
|
|
public function __construct( |
|
39
|
|
|
Context $context, |
|
|
|
|
|
|
40
|
|
|
Registry $registry, |
|
41
|
|
|
AbstractResource $resource = null, |
|
42
|
|
|
AbstractDb $resourceCollection = null, |
|
43
|
|
|
string $resourceModelClass, |
|
44
|
|
|
string $cacheTag, |
|
45
|
|
|
array $data = [] |
|
46
|
|
|
) { |
|
47
|
|
|
$this->resourceModelClass = $resourceModelClass; |
|
48
|
|
|
$this->cacheTag = $cacheTag; |
|
49
|
|
|
parent::__construct($context, $registry, $resource, $resourceCollection, $data); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
protected function _construct() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->_init($this->resourceModelClass); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function getIdentities() |
|
58
|
|
|
{ |
|
59
|
|
|
return [$this->cacheTag . '_' . $this->getId()]; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|