1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* API for Billing |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/billing-hiapi |
6
|
|
|
* @package billing-hiapi |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hiqdev\billing\hiapi\action; |
12
|
|
|
|
13
|
|
|
use hiqdev\php\billing\action\ActionInterface; |
14
|
|
|
use hiqdev\php\billing\action\ActionQuery; |
15
|
|
|
use hiqdev\yii\DataMapper\components\ConnectionInterface; |
16
|
|
|
use hiqdev\yii\DataMapper\components\EntityManagerInterface; |
17
|
|
|
use hiqdev\yii\DataMapper\expressions\CallExpression; |
18
|
|
|
use hiqdev\yii\DataMapper\expressions\HstoreExpression; |
19
|
|
|
use hiqdev\yii\DataMapper\repositories\BaseRepository; |
20
|
|
|
use yii\db\Query; |
21
|
|
|
|
22
|
|
|
class ActionRepository extends BaseRepository |
23
|
|
|
{ |
24
|
|
|
public $queryClass = ActionQuery::class; |
25
|
|
|
|
26
|
|
|
public function save(ActionInterface $action) |
27
|
|
|
{ |
28
|
|
|
$sale = $action->getSale(); |
29
|
|
|
$time = $action->getTime(); |
30
|
|
|
$hstore = new HstoreExpression(array_filter([ |
31
|
|
|
'id' => $action->getId(), |
32
|
|
|
'parent_id' => $action->hasParent() ? $action->getParent()->getId() : null, |
33
|
|
|
'object_id' => $action->getTarget()->getId(), |
34
|
|
|
'type' => $action->getType()->getName(), |
35
|
|
|
'type_id' => $action->getType()->getId(), |
36
|
|
|
'amount' => $action->getQuantity()->getQuantity(), |
37
|
|
|
'sale_id' => $sale ? $this->em->findId($sale) : null, |
38
|
|
|
'state' => $action->getState() ? $action->getState()->getName() : null, |
|
|
|
|
39
|
|
|
'time' => $time ? $time->format('c') : null, |
40
|
|
|
])); |
41
|
|
|
$call = new CallExpression('set_action', [$hstore]); |
42
|
|
|
$command = (new Query())->select($call); |
43
|
|
|
$action->setId($command->scalar($this->db)); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.