Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
UrlCheck Class Reference
Inheritance diagram for UrlCheck:

Public Member Functions

 __construct (UrlValidator $urlValidator)
 
 indexAction ()
 

Detailed Description

Definition at line 13 of file UrlCheck.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( UrlValidator  $urlValidator)
Parameters
UrlValidator$urlValidator

Definition at line 23 of file UrlCheck.php.

24  {
25  $this->urlValidator = $urlValidator;
26  }

Member Function Documentation

◆ indexAction()

indexAction ( )

Validate URL

Returns
JsonModel

Definition at line 33 of file UrlCheck.php.

34  {
35  $params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
36  $result = ['successUrl' => false, 'successSecureUrl' => true];
37 
38  $hasBaseUrl = isset($params['address']['actual_base_url']);
39  $hasSecureBaseUrl = isset($params['https']['text']);
40  $hasSecureAdminUrl = !empty($params['https']['admin']);
41  $hasSecureFrontUrl = !empty($params['https']['front']);
42  $schemes = ['http', 'https'];
43 
44  // Validating of Base URL
45  if ($hasBaseUrl && $this->urlValidator->isValid($params['address']['actual_base_url'], $schemes)) {
46  $result['successUrl'] = true;
47  }
48 
49  // Validating of Secure Base URL
50  if ($hasSecureAdminUrl || $hasSecureFrontUrl) {
51  if (!($hasSecureBaseUrl && $this->urlValidator->isValid($params['https']['text'], $schemes))) {
52  $result['successSecureUrl'] = false;
53  }
54  }
55 
56  return new JsonModel($result);
57  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

The documentation for this class was generated from the following file: