예제 #1
0
파일: PageManager.php 프로젝트: spryker/Cms
 /**
  * @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;
 }
예제 #2
0
 /**
  * @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;
 }
예제 #3
0
파일: CmsPageForm.php 프로젝트: spryker/Cms
 /**
  * @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;
 }