new: [metafields-types:ipv6] Support of ipv6
parent
0363a91310
commit
9fe7f06265
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace MetaFieldsTypes;
|
||||
|
||||
use MetaFieldsTypes\IPv4Type;
|
||||
|
||||
class IPv6Type extends IPv4Type
|
||||
{
|
||||
public const TYPE = 'ipv6';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function _isValidIP(string $value): bool
|
||||
{
|
||||
return filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
|
||||
}
|
||||
|
||||
}
|
|
@ -12,8 +12,10 @@ use Cake\Database\Expression\QueryExpression;
|
|||
|
||||
use MetaFieldsTypes\TextType;
|
||||
use MetaFieldsTypes\IPv4Type;
|
||||
use MetaFieldsTypes\IPv6Type;
|
||||
require_once(APP . 'Lib' . DS . 'default' . DS . 'meta_fields_types' . DS . 'TextType.php');
|
||||
require_once(APP . 'Lib' . DS . 'default' . DS . 'meta_fields_types' . DS . 'IPv4Type.php');
|
||||
require_once(APP . 'Lib' . DS . 'default' . DS . 'meta_fields_types' . DS . 'IPv6Type.php');
|
||||
|
||||
class MetaFieldsBehavior extends Behavior
|
||||
{
|
||||
|
@ -63,6 +65,7 @@ class MetaFieldsBehavior extends Behavior
|
|||
$typeHandlers = [
|
||||
new TextType(),
|
||||
new IPv4Type(),
|
||||
new IPv6Type(),
|
||||
];
|
||||
foreach ($typeHandlers as $handler) {
|
||||
$this->typeHandlers[$handler::TYPE] = $handler;
|
||||
|
|
Loading…
Reference in New Issue