Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Lastmod.php
Go to the documentation of this file.
1 <?php
26 #require_once 'Zend/Validate/Abstract.php';
27 
40 {
45  const LASTMOD_REGEX = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])(T([0-1][0-9]|2[0-3])(:[0-5][0-9])(:[0-5][0-9])?(\\+|-)([0-1][0-9]|2[0-3]):[0-5][0-9])?$/';
46 
51  const NOT_VALID = 'sitemapLastmodNotValid';
52  const INVALID = 'sitemapLastmodInvalid';
53 
59  protected $_messageTemplates = array(
60  self::NOT_VALID => "'%value%' is not a valid sitemap lastmod",
61  self::INVALID => "Invalid type given. String expected",
62  );
63 
72  public function isValid($value)
73  {
74  if (!is_string($value)) {
75  $this->_error(self::INVALID);
76  return false;
77  }
78 
79  $this->_setValue($value);
80  $result = @preg_match(self::LASTMOD_REGEX, $value);
81  if ($result != 1) {
82  $this->_error(self::NOT_VALID);
83  return false;
84  }
85 
86  return true;
87  }
88 }
_error($messageKey, $value=null)
Definition: Abstract.php:284
$value
Definition: gender.phtml:16