/** * @param \Generated\Shared\Transfer\PageTransfer $pageTransfer * * @return \Generated\Shared\Transfer\UrlTransfer */ public function savePageUrlAndTouch(PageTransfer $pageTransfer) { if (!$this->hasPageId($pageTransfer->getIdCmsPage())) { $pageTransfer = $this->savePage($pageTransfer); } $urlTransfer = $this->createPageUrl($pageTransfer); $this->urlFacade->touchUrlActive($urlTransfer->getIdUrl()); return $urlTransfer; }
/** * @return array */ protected function getUrlConstraints() { $urlConstraints = $this->getMandatoryConstraints(); $urlConstraints[] = new Callback(['methods' => [function ($url, ExecutionContextInterface $context) { if ($this->urlFacade->hasUrl($url)) { $context->addViolation('URL is already used'); } }], 'groups' => [self::GROUP_UNIQUE_URL_CHECK]]); return $urlConstraints; }
/** * @return array */ protected function getUrlConstraints() { $urlConstraints = [new Required(), new NotBlank(), new Length(['max' => 255]), new Callback(['methods' => [function ($url, ExecutionContextInterface $context) { if ($this->urlFacade->hasUrl($url)) { $context->addViolation('URL is already used'); } if ($url[0] !== '/') { $context->addViolation('URL must start with a slash'); } }], 'groups' => [self::GROUP_UNIQUE_URL_CHECK]])]; return $urlConstraints; }