Skip to content

Commit c948bd7

Browse files
committed
fix
1 parent f179369 commit c948bd7

File tree

1 file changed

+66
-10
lines changed

1 file changed

+66
-10
lines changed

Block/Adminhtml/System/ListLicense.php

+66-10
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ class ListLicense extends \Magento\Config\Block\System\Config\Form\Field
5555
*/
5656
protected $_license;
5757

58+
/**
59+
* @var array
60+
*/
5861
private $_list_files = [];
5962

6063
/**
@@ -79,7 +82,13 @@ public function __construct(
7982
$this->_license = $license;
8083
}
8184

82-
public function getListLicenseFiles() {
85+
/**
86+
* get list license files
87+
*
88+
* @return mixed
89+
*/
90+
public function getListLicenseFiles()
91+
{
8392
if(!$this->_list_files) {
8493
$path = $this->_filesystem->getDirectoryRead(DirectoryList::APP)->getAbsolutePath('code/Lof/');
8594
$files = glob($path . '*/*/license.xml');
@@ -117,6 +126,7 @@ public function getListLicenseFiles() {
117126
}
118127
return $this->_list_files;
119128
}
129+
120130
/**
121131
* Retrieve HTML markup for given form element
122132
*
@@ -316,13 +326,18 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
316326
}
317327
return $this->_decorateRowHtml($element, $html);
318328
}
319-
public function getProductList() {
320-
try{
329+
330+
/**
331+
* Api get product list
332+
*/
333+
public function getProductList()
334+
{
335+
try {
321336
//Authentication rest API magento2, get access token
322337
$url = self::getListUrl();
323338
$direct_url = $url."?pc_list=true";
324339
$response = @file_get_contents($direct_url);
325-
if(!$response) {
340+
if (!$response) {
326341
$key_path = $this->getKeyPath();
327342
$data = array("pc_list"=>true);
328343
$crl = curl_init();
@@ -353,7 +368,16 @@ public function getProductList() {
353368
return [];
354369
}
355370

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+
{
357381
try{
358382
//Authentication rest API magento2, get access token
359383
$url = self::getVerifyUrl();
@@ -390,15 +414,30 @@ public function verifyLicense($license_key, $extension, $domain, $ip) {
390414
}
391415
return [];
392416
}
393-
public static function getListUrl() {
417+
418+
/**
419+
* @return string
420+
*/
421+
public static function getListUrl()
422+
{
394423
$url = ListLicense::SITE_URL;
395424
return $url."/license/listproducts";
396425
}
397-
public static function getVerifyUrl() {
426+
427+
/**
428+
* @return string
429+
*/
430+
public static function getVerifyUrl()
431+
{
398432
$url = ListLicense::SITE_URL;
399433
return $url."/license/verify";
400434
}
401-
public function getKeyPath(){
435+
436+
/**
437+
* @return string
438+
*/
439+
public function getKeyPath()
440+
{
402441
if(!$this->_key_path){
403442
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
404443
$directory = $objectManager->get('\Magento\Framework\Filesystem\DirectoryList');
@@ -407,15 +446,32 @@ public function getKeyPath(){
407446
}
408447
return $this->_key_path;
409448
}
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+
{
411458
$domain = strtolower($domain);
412459
$domain = str_replace(['www.','WWW.','https://','http://','https','http'], [''], $domain);
413460
if($this->endsWith($domain, '/')){
414461
$domain = substr_replace($domain ,"",-1);
415462
}
416463
return $domain;
417464
}
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+
{
419475
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== false);
420476
}
421477
}

0 commit comments

Comments
 (0)