1515use Magento \MediaContentApi \Api \GetContentByAssetIdsInterface ;
1616use Magento \Ui \Component \Filters \FilterModifier ;
1717use 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 ;
2218
2319/**
24- * Asset filter
20+ * Asset filter
2521 */
2622class Asset extends Select
2723{
28- /**
29- * @var BookmarkManagementInterface
30- */
31- private $ bookmarkManagement ;
32-
3324 /**
3425 * @var GetContentByAssetIdsInterface
3526 */
3627 private $ getContentIdentities ;
3728
3829 /**
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- *
5630 * @param ContextInterface $context
5731 * @param UiComponentFactory $uiComponentFactory
5832 * @param FilterBuilder $filterBuilder
5933 * @param FilterModifier $filterModifier
6034 * @param OptionSourceInterface $optionsProvider
6135 * @param GetContentByAssetIdsInterface $getContentIdentities
62- * @param BookmarkManagementInterface $bookmarkManagement
63- * @param GetAssetsByIdsInterface $getAssetsByIds
64- * @param Images $images
65- * @param Storage $storage
6636 * @param array $components
6737 * @param array $data
68- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
6938 */
7039 public function __construct (
7140 ContextInterface $ context ,
@@ -74,10 +43,6 @@ public function __construct(
7443 FilterModifier $ filterModifier ,
7544 OptionSourceInterface $ optionsProvider = null ,
7645 GetContentByAssetIdsInterface $ getContentIdentities ,
77- BookmarkManagementInterface $ bookmarkManagement ,
78- GetAssetsByIdsInterface $ getAssetsByIds ,
79- Images $ images ,
80- Storage $ storage ,
8146 array $ components = [],
8247 array $ data = []
8348 ) {
@@ -93,69 +58,6 @@ public function __construct(
9358 $ data
9459 );
9560 $ 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 ();
15961 }
16062
16163 /**
0 commit comments