@@ -27,6 +27,7 @@ class InformationModel implements InformationInterface
27
27
protected $ startup ;
28
28
protected $ collectionFactory ;
29
29
protected $ appsFactory ;
30
+ protected $ date ;
30
31
31
32
public function __construct (
32
33
Context $ context ,
@@ -36,7 +37,6 @@ public function __construct(
36
37
\Magento \Framework \Webapi \Rest \Request $ request ,
37
38
\Magento \Framework \Filesystem \Driver \File $ driver ,
38
39
\Magento \Catalog \Model \ResourceModel \Product \CollectionFactory $ productFactory ,
39
- // \Vuefront\Vuefront\Model\ResourceModel\Apps\Collection $appsFactory,
40
40
\Vuefront \Vuefront \Model \Api \System \Startup $ startup ,
41
41
\Magento \Store \Model \StoreManagerInterface $ storeManager ,
42
42
\Magento \Framework \Module \Manager $ moduleManager ,
@@ -48,7 +48,8 @@ public function __construct(
48
48
\Zend \Validator \File \Exists $ zendFileExists ,
49
49
\Magento \Framework \Filesystem \Io \File $ file ,
50
50
\Magento \Framework \Archive \Tar $ arhiveTar ,
51
- \Vuefront \Vuefront \Model \AppsFactory $ appsFactory
51
+ \Vuefront \Vuefront \Model \AppsFactory $ appsFactory ,
52
+ \Magento \Framework \Stdlib \DateTime \DateTime $ date
52
53
) {
53
54
$ this ->scopeConfig = $ scopeConfig ;
54
55
$ this ->context = $ context ;
@@ -70,6 +71,7 @@ public function __construct(
70
71
$ this ->file = $ file ;
71
72
$ this ->zendHttp = $ zendHttp ;
72
73
$ this ->arhiveTar = $ arhiveTar ;
74
+ $ this ->date = $ date ;
73
75
}
74
76
75
77
public function checkCors ()
@@ -342,14 +344,43 @@ public function vfApps() {
342
344
$ apps = $ this ->appsFactory ->create ();
343
345
$ collection = $ apps ->getCollection ();
344
346
347
+ $ result = [];
348
+
345
349
foreach ($ collection as $ key => $ value ) {
346
- var_dump ($ value ->getData ());
350
+ $ data = $ value ->getData ();
351
+ $ result [] = [
352
+ 'codename ' => $ data ['codename ' ],
353
+ 'jwt ' => $ data ['jwt ' ],
354
+ 'date_added ' => $ data ['date_added ' ]
355
+ ];
347
356
}
348
357
358
+ return $ result ;
359
+ }
360
+
361
+ public function vfAppsCreate ($ post ) {
362
+ $ app = $ this ->appsFactory ->create ();
363
+ $ app ->setCodename ($ post ['codename ' ]);
364
+ $ app ->setJwt ($ post ['jwt ' ]);
365
+ $ app ->setDateAdded ($ this ->date ->gmtDate ());
366
+ $ app ->save ();
349
367
return [];
350
368
}
351
369
352
- public function vfAppsCreate () {
370
+ public function vfAppsRemove ($ post ) {
371
+ $ app = $ this ->appsFactory ->create ()->getCollection ();
372
+ $ app ->addFieldToSelect ('* ' );
373
+ $ app ->setCurPage ($ post ['key ' ] + 1 );
374
+ $ app ->setPageSize (1 );
375
+
376
+ $ result = $ app ->load ();
377
+
378
+ foreach ($ result ->getItems () as $ key => $ value ) {
379
+ var_dump ($ value ->getAppId ());
380
+ $ model = $ this ->appsFactory ->create ();
381
+ $ model ->load ($ value ->getAppId ());
382
+ $ model ->delete ();
383
+ }
353
384
return [];
354
385
}
355
386
@@ -363,7 +394,10 @@ public function info()
363
394
$ result = $ this ->vfApps ();
364
395
break ;
365
396
case 'vf_apps_create ' :
366
- $ result = $ this ->vfAppsCreate ();
397
+ $ result = $ this ->vfAppsCreate ($ this ->request ->getBodyParams ());
398
+ break ;
399
+ case 'vf_apps_remove ' :
400
+ $ result = $ this ->vfAppsRemove ($ this ->request ->getBodyParams ());
367
401
break ;
368
402
case 'vf_information ' :
369
403
$ result = $ this ->vfInformation ();
0 commit comments