|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2020 |
|
6
|
|
|
* @package Admin |
|
7
|
|
|
* @subpackage JsonAdm |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Admin\JsonAdm\Service; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* JSON API service client |
|
16
|
|
|
* |
|
17
|
|
|
* @package Admin |
|
18
|
|
|
* @subpackage JsonAdm |
|
19
|
|
|
*/ |
|
20
|
|
|
class Standard |
|
21
|
|
|
extends \Aimeos\Admin\JsonAdm\Standard |
|
22
|
|
|
implements \Aimeos\Admin\JsonAdm\Common\Iface |
|
23
|
|
|
{ |
|
24
|
|
|
/** admin/jsonadm/service/decorators/excludes |
|
25
|
|
|
* Excludes decorators added by the "common" option from the JSON API clients |
|
26
|
|
|
* |
|
27
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
28
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
29
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
30
|
|
|
* modify what is returned to the caller. |
|
31
|
|
|
* |
|
32
|
|
|
* This option allows you to remove a decorator added via |
|
33
|
|
|
* "admin/jsonadm/common/decorators/default" before they are wrapped |
|
34
|
|
|
* around the Jsonadm client. |
|
35
|
|
|
* |
|
36
|
|
|
* admin/jsonadm/decorators/excludes = array( 'decorator1' ) |
|
37
|
|
|
* |
|
38
|
|
|
* This would remove the decorator named "decorator1" from the list of |
|
39
|
|
|
* common decorators ("\Aimeos\Admin\JsonAdm\Common\Decorator\*") added via |
|
40
|
|
|
* "admin/jsonadm/common/decorators/default" for the JSON API client. |
|
41
|
|
|
* |
|
42
|
|
|
* @param array List of decorator names |
|
43
|
|
|
* @since 2016.01 |
|
44
|
|
|
* @category Developer |
|
45
|
|
|
* @see admin/jsonadm/common/decorators/default |
|
46
|
|
|
* @see admin/jsonadm/service/decorators/global |
|
47
|
|
|
* @see admin/jsonadm/service/decorators/local |
|
48
|
|
|
*/ |
|
49
|
|
|
|
|
50
|
|
|
/** admin/jsonadm/service/decorators/global |
|
51
|
|
|
* Adds a list of globally available decorators only to the Jsonadm client |
|
52
|
|
|
* |
|
53
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
54
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
55
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
56
|
|
|
* modify what is returned to the caller. |
|
57
|
|
|
* |
|
58
|
|
|
* This option allows you to wrap global decorators |
|
59
|
|
|
* ("\Aimeos\Admin\Jsonadm\Common\Decorator\*") around the Jsonadm |
|
60
|
|
|
* client. |
|
61
|
|
|
* |
|
62
|
|
|
* admin/jsonadm/service/decorators/global = array( 'decorator1' ) |
|
63
|
|
|
* |
|
64
|
|
|
* This would add the decorator named "decorator1" defined by |
|
65
|
|
|
* "\Aimeos\Admin\Jsonadm\Common\Decorator\Decorator1" only to the |
|
66
|
|
|
* "service" Jsonadm client. |
|
67
|
|
|
* |
|
68
|
|
|
* @param array List of decorator names |
|
69
|
|
|
* @since 2016.01 |
|
70
|
|
|
* @category Developer |
|
71
|
|
|
* @see admin/jsonadm/common/decorators/default |
|
72
|
|
|
* @see admin/jsonadm/service/decorators/excludes |
|
73
|
|
|
* @see admin/jsonadm/service/decorators/local |
|
74
|
|
|
*/ |
|
75
|
|
|
|
|
76
|
|
|
/** admin/jsonadm/service/decorators/local |
|
77
|
|
|
* Adds a list of local decorators only to the Jsonadm client |
|
78
|
|
|
* |
|
79
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
80
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
81
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
82
|
|
|
* modify what is returned to the caller. |
|
83
|
|
|
* |
|
84
|
|
|
* This option allows you to wrap local decorators |
|
85
|
|
|
* ("\Aimeos\Admin\Jsonadm\Service\Decorator\*") around the Jsonadm |
|
86
|
|
|
* client. |
|
87
|
|
|
* |
|
88
|
|
|
* admin/jsonadm/service/decorators/local = array( 'decorator2' ) |
|
89
|
|
|
* |
|
90
|
|
|
* This would add the decorator named "decorator2" defined by |
|
91
|
|
|
* "\Aimeos\Admin\Jsonadm\Service\Decorator\Decorator2" only to the |
|
92
|
|
|
* "service" Jsonadm client. |
|
93
|
|
|
* |
|
94
|
|
|
* @param array List of decorator names |
|
95
|
|
|
* @since 2016.01 |
|
96
|
|
|
* @category Developer |
|
97
|
|
|
* @see admin/jsonadm/common/decorators/default |
|
98
|
|
|
* @see admin/jsonadm/service/decorators/excludes |
|
99
|
|
|
* @see admin/jsonadm/service/decorators/global |
|
100
|
|
|
*/ |
|
101
|
|
|
|
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Returns the list items for association relationships |
|
105
|
|
|
* |
|
106
|
|
|
* @param \Aimeos\Map $items List of items implementing \Aimeos\MShop\Common\Item\Iface |
|
107
|
|
|
* @param array $include List of resource types that should be fetched |
|
108
|
|
|
* @return \Aimeos\Map List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
|
109
|
|
|
*/ |
|
110
|
|
|
protected function getListItems( \Aimeos\Map $items, array $include ) : \Aimeos\Map |
|
111
|
|
|
{ |
|
112
|
|
|
$manager = \Aimeos\MShop::create( $this->getContext(), 'service/lists' ); |
|
113
|
|
|
|
|
114
|
|
|
$search = $manager->createSearch(); |
|
115
|
|
|
$expr = array( |
|
116
|
|
|
$search->compare( '==', 'service.lists.parentid', $items->keys()->toArray() ), |
|
117
|
|
|
$search->compare( '==', 'service.lists.domain', $include ), |
|
118
|
|
|
); |
|
119
|
|
|
$search->setConditions( $search->combine( '&&', $expr ) ); |
|
120
|
|
|
|
|
121
|
|
|
return $manager->searchItems( $search ); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Saves and returns the new or updated item |
|
126
|
|
|
* |
|
127
|
|
|
* @param \Aimeos\MShop\Common\Manager\Iface $manager Manager responsible for the items |
|
128
|
|
|
* @param \stdClass $entry Object including "id" and "attributes" elements |
|
129
|
|
|
* @return \Aimeos\MShop\Common\Item\Iface New or updated item |
|
130
|
|
|
*/ |
|
131
|
|
|
protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) : \Aimeos\MShop\Common\Item\Iface |
|
132
|
|
|
{ |
|
133
|
|
|
if( isset( $entry->id ) ) { |
|
134
|
|
|
$item = $manager->getItem( $entry->id ); |
|
135
|
|
|
} else { |
|
136
|
|
|
$item = $manager->createItem(); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
if( isset( $entry->attributes ) && ( $attr = (array) $entry->attributes ) ) { |
|
140
|
|
|
if( isset( $attr["service.config"] ) ) { |
|
141
|
|
|
$attr["service.config"] = (array) $attr["service.config"]; |
|
142
|
|
|
} |
|
143
|
|
|
$item = $item->fromArray( $attr, true ); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
$item = $manager->saveItem( $item ); |
|
|
|
|
|
|
147
|
|
|
|
|
148
|
|
|
if( isset( $entry->relationships ) ) { |
|
149
|
|
|
$this->saveRelationships( $manager, $item, $entry->relationships ); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
return $manager->getItem( $item->getId() ); |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|
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.