示例#1
0
文件: CleanURL.php 项目: kingsj/core
 /**
  * Validate
  *
  * @param mixed $data Data
  *
  * @return void
  * @throws \XLite\Core\Validator\Exception
  */
 public function validate($data)
 {
     if (!\XLite\Core\Converter::isEmptyString($data)) {
         parent::validate($data);
         $entity = \XLite\Core\Database::getRepo($this->class)->findOneByCleanURL($this->sanitize($data));
         // DO NOT use "!==" here
         if ($entity && (empty($this->id) || $entity->getUniqueIdentifier() != $this->id)) {
             $this->throwCleanURLError();
         }
     }
 }
示例#2
0
 /**
  * Validate
  *
  * @param mixed $data Data
  *
  * @return void
  * @throws \XLite\Core\Validator\Exception
  */
 public function validate($data)
 {
     $data = $this->sanitize($data);
     if (!\XLite\Core\Converter::isEmptyString($data)) {
         parent::validate($data);
         /** @var \XLite\Model\Repo\CleanURL $repo */
         $repo = \XLite\Core\Database::getRepo('XLite\\Model\\CleanURL');
         $postedData = \XLite\Core\Request::getInstance()->postedData;
         if (!isset($postedData['forceCleanURL']) && !$repo->isURLUnique($data, $this->class, $this->id)) {
             $this->throwCleanURLError($data);
         }
     }
 }