コード例 #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
ファイル: CleanURL.php プロジェクト: kirkbauer2/kirkxc
 /**
  * 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);
         }
     }
 }