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