95 \
Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
97 \
Magento\Framework\Locale\ResolverInterface $localeResolver
99 $this->_localeDate = $localeDate;
101 $this->_localeResolver = $localeResolver;
125 if (!$this->_attribute) {
126 throw new CoreException(
__(
'Attribute object is undefined'));
140 $this->_requestScope = $scope;
154 $this->_requestScopeOnly = (bool)$flag;
179 if (!$this->_entity) {
180 throw new CoreException(
__(
'Entity object is undefined'));
194 $this->_extractedData =
$data;
207 if (isset($this->_extractedData[
$index])) {
208 return $this->_extractedData[
$index];
244 $filterClass =
'Magento\Framework\Data\Form\Filter\\' . ucfirst($filterCode);
245 if ($filterCode ==
'date') {
248 $filter =
new $filterClass();
310 $validateRules = $this->
getAttribute()->getValidateRules();
312 if (!empty($validateRules[
'input_validation'])) {
314 switch ($validateRules[
'input_validation']) {
316 $validator = new \Zend_Validate_Alnum(
true);
318 $validator->setMessage(
319 __(
'"%1" contains non-alphabetic or non-numeric characters.',
$label),
323 if (!$validator->isValid(
$value)) {
324 return $validator->getMessages();
328 $validator = new \Zend_Validate_Digits();
330 $validator->setMessage(
331 __(
'"%1" contains non-numeric characters.',
$label),
334 $validator->setMessage(
335 __(
'"%1" is an empty string.',
$label),
338 if (!$validator->isValid(
$value)) {
339 return $validator->getMessages();
343 $validator = new \Zend_Validate_Alpha(
true);
345 $validator->setMessage(
346 __(
'"%1" contains non-alphabetic characters.',
$label),
350 if (!$validator->isValid(
$value)) {
351 return $validator->getMessages();
370 $validator->setMessage(
371 __(
'"%1" invalid type entered.',
$label),
374 $validator->setMessage(
375 __(
'"%1" is not a valid email address.',
$label),
378 $validator->setMessage(
379 __(
'"%1" is not a valid hostname.',
$label),
382 $validator->setMessage(
383 __(
'"%1" is not a valid hostname.',
$label),
386 $validator->setMessage(
387 __(
'"%1" is not a valid hostname.',
$label),
390 $validator->setMessage(
391 __(
'"%1" is not a valid email address.',
$label),
394 $validator->setMessage(
395 __(
'"%1" is not a valid email address.',
$label),
398 $validator->setMessage(
399 __(
'"%1" is not a valid email address.',
$label),
402 $validator->setMessage(
403 __(
'"%1" uses too many characters.',
$label),
406 $validator->setMessage(
407 __(
"'%value%' looks like an IP address, which is not an acceptable format."),
410 $validator->setMessage(
411 __(
"'%value%' looks like a DNS hostname but contains a dash in an invalid position."),
414 $validator->setMessage(
416 "'%value%' looks like a DNS hostname but we cannot match it against the " 417 .
"hostname schema for TLD '%tld%'." 421 $validator->setMessage(
422 __(
"'%value%' looks like a DNS hostname but cannot extract TLD part."),
425 $validator->setMessage(
426 __(
"'%value%' does not look like a valid local network name."),
429 $validator->setMessage(
430 __(
"'%value%' looks like a local network name, which is not an acceptable format."),
433 $validator->setMessage(
435 "'%value%' appears to be a DNS hostname, but the given punycode notation cannot be decoded." 439 if (!$validator->isValid(
$value)) {
440 return array_unique($validator->getMessages());
444 $parsedUrl = parse_url(
$value);
445 if ($parsedUrl ===
false || empty($parsedUrl[
'scheme']) || empty($parsedUrl[
'host'])) {
446 return [
__(
'"%1" is not a valid URL.',
$label)];
448 $validator = new \Zend_Validate_Hostname();
449 if (!$validator->isValid($parsedUrl[
'host'])) {
450 return [
__(
'"%1" is not a valid URL.',
$label)];
454 $validator = new \Zend_Validate_Date(
456 'format' => \
Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT,
457 'locale' => $this->_localeResolver->getLocale(),
462 $validator->setMessage(
463 __(
'"%1" does not fit the entered date format.',
$label),
466 if (!$validator->isValid(
$value)) {
467 return array_unique($validator->getMessages());
485 $this->_isAjax = (bool)$flag;
510 if ($this->_requestScope) {
511 if (strpos($this->_requestScope,
'/') !==
false) {
513 $parts = explode(
'/', $this->_requestScope);
514 foreach ($parts as $part) {
525 if (isset(
$params[$attrCode])) {
531 if (!$this->_requestScopeOnly &&
$value ===
false) {
_applyInputFilter($value)
const INVALID_HOSTNAME_SCHEMA
elseif(isset( $params[ 'redirect_parent']))
getExtractedData($index=null)
__construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Locale\ResolverInterface $localeResolver)
setRequestScopeOnly($flag)
_getRequestValue(RequestInterface $request)
setAttribute(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute)
outputValue($format=\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT)
extractValue(RequestInterface $request)
setExtractedData(array $data)
const CANNOT_DECODE_PUNYCODE
setIsAjaxRequest($flag=true)
_dateFilterFormat($format=null)
const IP_ADDRESS_NOT_ALLOWED
_validateInputRule($value)
setEntity(\Magento\Framework\Model\AbstractModel $entity)
_applyOutputFilter($value)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
const LOCAL_NAME_NOT_ALLOWED