new: [metafields-types:ipv6] Support of ipv6

pull/93/head
Sami Mokaddem 2022-02-28 09:45:43 +01:00
parent 0363a91310
commit 9fe7f06265
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 24 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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;