Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AllowedProtocols.php
Go to the documentation of this file.
1 <?php
9 
10 use \Zend\Uri\Uri;
11 
19 {
25  private $listOfProtocols = [
26  'http',
27  'https',
28  ];
29 
34  public function __construct($listOfProtocols = [])
35  {
36  if (count($listOfProtocols)) {
37  $this->listOfProtocols = $listOfProtocols;
38  }
39  }
40 
47  public function isValid($value)
48  {
49  $uri = new Uri($value);
50  $isValid = in_array(
51  strtolower($uri->getScheme()),
52  $this->listOfProtocols
53  );
54  if (!$isValid) {
55  $this->_addMessages(["Protocol isn't allowed"]);
56  }
57  return $isValid;
58  }
59 }
$value
Definition: gender.phtml:16