@@ -55,6 +55,9 @@ class ListLicense extends \Magento\Config\Block\System\Config\Form\Field
55
55
*/
56
56
protected $ _license ;
57
57
58
+ /**
59
+ * @var array
60
+ */
58
61
private $ _list_files = [];
59
62
60
63
/**
@@ -79,7 +82,13 @@ public function __construct(
79
82
$ this ->_license = $ license ;
80
83
}
81
84
82
- public function getListLicenseFiles () {
85
+ /**
86
+ * get list license files
87
+ *
88
+ * @return mixed
89
+ */
90
+ public function getListLicenseFiles ()
91
+ {
83
92
if (!$ this ->_list_files ) {
84
93
$ path = $ this ->_filesystem ->getDirectoryRead (DirectoryList::APP )->getAbsolutePath ('code/Lof/ ' );
85
94
$ files = glob ($ path . '*/*/license.xml ' );
@@ -117,6 +126,7 @@ public function getListLicenseFiles() {
117
126
}
118
127
return $ this ->_list_files ;
119
128
}
129
+
120
130
/**
121
131
* Retrieve HTML markup for given form element
122
132
*
@@ -316,13 +326,18 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
316
326
}
317
327
return $ this ->_decorateRowHtml ($ element , $ html );
318
328
}
319
- public function getProductList () {
320
- try {
329
+
330
+ /**
331
+ * Api get product list
332
+ */
333
+ public function getProductList ()
334
+ {
335
+ try {
321
336
//Authentication rest API magento2, get access token
322
337
$ url = self ::getListUrl ();
323
338
$ direct_url = $ url ."?pc_list=true " ;
324
339
$ response = @file_get_contents ($ direct_url );
325
- if (!$ response ) {
340
+ if (!$ response ) {
326
341
$ key_path = $ this ->getKeyPath ();
327
342
$ data = array ("pc_list " =>true );
328
343
$ crl = curl_init ();
@@ -353,7 +368,16 @@ public function getProductList() {
353
368
return [];
354
369
}
355
370
356
- public function verifyLicense ($ license_key , $ extension , $ domain , $ ip ) {
371
+ /**
372
+ * verify license
373
+ * @param string $license_key
374
+ * @param string $extension
375
+ * @param string $domain
376
+ * @param string $ip
377
+ * @return mixed
378
+ */
379
+ public function verifyLicense ($ license_key , $ extension , $ domain , $ ip )
380
+ {
357
381
try {
358
382
//Authentication rest API magento2, get access token
359
383
$ url = self ::getVerifyUrl ();
@@ -390,15 +414,30 @@ public function verifyLicense($license_key, $extension, $domain, $ip) {
390
414
}
391
415
return [];
392
416
}
393
- public static function getListUrl () {
417
+
418
+ /**
419
+ * @return string
420
+ */
421
+ public static function getListUrl ()
422
+ {
394
423
$ url = ListLicense::SITE_URL ;
395
424
return $ url ."/license/listproducts " ;
396
425
}
397
- public static function getVerifyUrl () {
426
+
427
+ /**
428
+ * @return string
429
+ */
430
+ public static function getVerifyUrl ()
431
+ {
398
432
$ url = ListLicense::SITE_URL ;
399
433
return $ url ."/license/verify " ;
400
434
}
401
- public function getKeyPath (){
435
+
436
+ /**
437
+ * @return string
438
+ */
439
+ public function getKeyPath ()
440
+ {
402
441
if (!$ this ->_key_path ){
403
442
$ objectManager = \Magento \Framework \App \ObjectManager::getInstance ();
404
443
$ directory = $ objectManager ->get ('\Magento\Framework\Filesystem\DirectoryList ' );
@@ -407,15 +446,32 @@ public function getKeyPath(){
407
446
}
408
447
return $ this ->_key_path ;
409
448
}
410
- public function getDomain ($ domain ) {
449
+
450
+ /**
451
+ * get domain
452
+ *
453
+ * @param string $domain
454
+ * @return string
455
+ */
456
+ public function getDomain ($ domain )
457
+ {
411
458
$ domain = strtolower ($ domain );
412
459
$ domain = str_replace (['www. ' ,'WWW. ' ,'https:// ' ,'http:// ' ,'https ' ,'http ' ], ['' ], $ domain );
413
460
if ($ this ->endsWith ($ domain , '/ ' )){
414
461
$ domain = substr_replace ($ domain ,"" ,-1 );
415
462
}
416
463
return $ domain ;
417
464
}
418
- public function endsWith ($ haystack , $ needle ) {
465
+
466
+ /**
467
+ * Ends with
468
+ *
469
+ * @param string $haystack
470
+ * @param string $needle
471
+ * @return bool
472
+ */
473
+ public function endsWith ($ haystack , $ needle )
474
+ {
419
475
return $ needle === "" || (($ temp = strlen ($ haystack ) - strlen ($ needle )) >= 0 && strpos ($ haystack , $ needle , $ temp ) !== false );
420
476
}
421
477
}
0 commit comments