15
15
use Magento \MediaContentApi \Api \GetContentByAssetIdsInterface ;
16
16
use Magento \Ui \Component \Filters \FilterModifier ;
17
17
use Magento \Ui \Component \Filters \Type \Select ;
18
- use Magento \Ui \Api \BookmarkManagementInterface ;
19
- use Magento \MediaGalleryApi \Api \GetAssetsByIdsInterface ;
20
- use Magento \Cms \Helper \Wysiwyg \Images ;
21
- use Magento \Cms \Model \Wysiwyg \Images \Storage ;
22
18
23
19
/**
24
- * Asset filter
20
+ * Asset filter
25
21
*/
26
22
class Asset extends Select
27
23
{
28
- /**
29
- * @var BookmarkManagementInterface
30
- */
31
- private $ bookmarkManagement ;
32
-
33
24
/**
34
25
* @var GetContentByAssetIdsInterface
35
26
*/
36
27
private $ getContentIdentities ;
37
28
38
29
/**
39
- * @var GetAssetsByIdsInterface
40
- */
41
- private $ getAssetsByIds ;
42
-
43
- /**
44
- * @var Images
45
- */
46
- private $ images ;
47
-
48
- /**
49
- * @var Storage
50
- */
51
- private $ storage ;
52
-
53
- /**
54
- * Constructor
55
- *
56
30
* @param ContextInterface $context
57
31
* @param UiComponentFactory $uiComponentFactory
58
32
* @param FilterBuilder $filterBuilder
59
33
* @param FilterModifier $filterModifier
60
34
* @param OptionSourceInterface $optionsProvider
61
35
* @param GetContentByAssetIdsInterface $getContentIdentities
62
- * @param BookmarkManagementInterface $bookmarkManagement
63
- * @param GetAssetsByIdsInterface $getAssetsByIds
64
- * @param Images $images
65
- * @param Storage $storage
66
36
* @param array $components
67
37
* @param array $data
68
- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
69
38
*/
70
39
public function __construct (
71
40
ContextInterface $ context ,
@@ -74,10 +43,6 @@ public function __construct(
74
43
FilterModifier $ filterModifier ,
75
44
OptionSourceInterface $ optionsProvider = null ,
76
45
GetContentByAssetIdsInterface $ getContentIdentities ,
77
- BookmarkManagementInterface $ bookmarkManagement ,
78
- GetAssetsByIdsInterface $ getAssetsByIds ,
79
- Images $ images ,
80
- Storage $ storage ,
81
46
array $ components = [],
82
47
array $ data = []
83
48
) {
@@ -93,69 +58,6 @@ public function __construct(
93
58
$ data
94
59
);
95
60
$ this ->getContentIdentities = $ getContentIdentities ;
96
- $ this ->bookmarkManagement = $ bookmarkManagement ;
97
- $ this ->getAssetsByIds = $ getAssetsByIds ;
98
- $ this ->images = $ images ;
99
- $ this ->storage = $ storage ;
100
- }
101
-
102
- /**
103
- * Prepare component configuration
104
- *
105
- * @return void
106
- */
107
- public function prepare ()
108
- {
109
- $ options = [];
110
- $ assetIds = [];
111
- $ bookmarks = $ this ->bookmarkManagement ->loadByNamespace ($ this ->context ->getNameSpace ())->getItems ();
112
- foreach ($ bookmarks as $ bookmark ) {
113
- if ($ bookmark ->getIdentifier () === 'current ' ) {
114
- $ applied = $ bookmark ->getConfig ()['current ' ]['filters ' ]['applied ' ];
115
- if (isset ($ applied [$ this ->getName ()])) {
116
- $ assetIds [] = $ applied [$ this ->getName ()];
117
- }
118
- }
119
- }
120
-
121
- $ assets = $ this ->getAssetsByIds ->execute ($ assetIds );
122
-
123
- foreach ($ assets as $ asset ) {
124
- $ assetPath = $ this ->storage ->getThumbnailUrl ($ this ->images ->getStorageRoot () . $ asset ->getPath ());
125
- $ options [] = [
126
- 'value ' => (string ) $ asset ->getId (),
127
- 'label ' => $ asset ->getTitle (),
128
- 'src ' => $ assetPath
129
- ];
130
- }
131
-
132
- $ this ->wrappedComponent = $ this ->uiComponentFactory ->create (
133
- $ this ->getName (),
134
- parent ::COMPONENT ,
135
- [
136
- 'context ' => $ this ->getContext (),
137
- 'options ' => $ options
138
- ]
139
- );
140
-
141
- $ this ->wrappedComponent ->prepare ();
142
- $ jsConfig = array_replace_recursive (
143
- $ this ->getJsConfig ($ this ->wrappedComponent ),
144
- $ this ->getJsConfig ($ this )
145
- );
146
- $ this ->setData ('js_config ' , $ jsConfig );
147
-
148
- $ this ->setData (
149
- 'config ' ,
150
- array_replace_recursive (
151
- (array )$ this ->wrappedComponent ->getData ('config ' ),
152
- (array )$ this ->getData ('config ' )
153
- )
154
- );
155
-
156
- $ this ->applyFilter ();
157
-
158
- parent ::prepare ();
159
61
}
160
62
161
63
/**
0 commit comments