-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
135 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_Webhook | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
|
||
namespace Mageplaza\Seo\Model\Config\Backend; | ||
|
||
use Magento\Framework\App\Config\Value; | ||
use Magento\Framework\Exception\ValidatorException; | ||
|
||
/** | ||
* Class ValidUrl | ||
* @package Mageplaza\Seo\Model\Config\Backend | ||
*/ | ||
class ValidUrl extends Value | ||
{ | ||
/** | ||
* @return Value|void | ||
* @throws ValidatorException | ||
*/ | ||
public function beforeSave() | ||
{ | ||
if (!empty($this->getValue())) { | ||
$valueArray = array_map('trim', explode( | ||
"\n", | ||
$this->getValue() | ||
?? '')); | ||
foreach ($valueArray as $value) { | ||
if (!filter_var($value, FILTER_VALIDATE_URL)) { | ||
throw new ValidatorException(__('Invalid url format.')); | ||
} | ||
} | ||
} | ||
parent::beforeSave(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.