/** * 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(); } } }
/** * 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); } } }