chg: [metafields] Passed argument can either be an object or array
parent
bb94765243
commit
134b7bfc3e
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Model\Table;
|
namespace App\Model\Table;
|
||||||
|
|
||||||
use App\Model\Entity\MetaTemplateField;
|
|
||||||
use App\Model\Table\AppTable;
|
use App\Model\Table\AppTable;
|
||||||
use Cake\ORM\Table;
|
use Cake\ORM\Table;
|
||||||
use Cake\Validation\Validator;
|
use Cake\Validation\Validator;
|
||||||
|
@ -66,15 +65,15 @@ class MetaFieldsTable extends AppTable
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isValidType($value, MetaTemplateField $metaTemplateField)
|
public function isValidType($value, $metaTemplateField)
|
||||||
{
|
{
|
||||||
if (empty($value)) {
|
if (empty($value)) {
|
||||||
return __('Metafield value cannot be empty.');
|
return __('Metafield value cannot be empty.');
|
||||||
}
|
}
|
||||||
$typeHandler = $this->MetaTemplateFields->getTypeHandler($metaTemplateField->type);
|
$typeHandler = $this->MetaTemplateFields->getTypeHandler($metaTemplateField['type']);
|
||||||
if (!empty($typeHandler)) {
|
if (!empty($typeHandler)) {
|
||||||
$success = $typeHandler->validate($value);
|
$success = $typeHandler->validate($value);
|
||||||
return $success ? true : __('Metafields value `{0}` for `{1}` doesn\'t pass type validation.', $value, $metaTemplateField->field);
|
return $success ? true : __('Metafields value `{0}` for `{1}` doesn\'t pass type validation.', $value, $metaTemplateField['field']);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
We should not end-up in this case. But if someone creates a new type without his handler,
|
We should not end-up in this case. But if someone creates a new type without his handler,
|
||||||
|
@ -86,9 +85,9 @@ class MetaFieldsTable extends AppTable
|
||||||
public function isValidRegex($value, $metaTemplateField)
|
public function isValidRegex($value, $metaTemplateField)
|
||||||
{
|
{
|
||||||
|
|
||||||
$re = $metaTemplateField->regex;
|
$re = $metaTemplateField['regex'];
|
||||||
if (!preg_match("/^$re$/m", $value)) {
|
if (!preg_match("/^$re$/m", $value)) {
|
||||||
return __('Metafield value `{0}` for `{1}` doesn\'t pass regex validation.', $value, $metaTemplateField->field);
|
return __('Metafield value `{0}` for `{1}` doesn\'t pass regex validation.', $value, $metaTemplateField['field']);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue