Exemplo n.º 1
0
 protected function setString($property, $value, $minLength, $maxLength = null)
 {
     if (isset($maxLength)) {
         if (!StringUtils::isLengthBetween($value, $minLength, $maxLength)) {
             throw new InvalidArgumentException();
         }
     } else {
         if (StringUtils::isUnderMinLength($value, $minLength)) {
             throw new InvalidArgumentException();
         }
     }
     $this->{$property} = $value;
 }
Exemplo n.º 2
0
 public function actionEdit($articleId, $tags = null, $photoId = null)
 {
     if ($articleId) {
         try {
             $editArticle = $this->articleFacade->findOneById($articleId);
             $this->template->editArticle = $editArticle;
             $this->template->tags = $editArticle->tags->items;
             $this->template->choosenPhoto = $editArticle->photo;
             $this->template->photoId = $editArticle->photo->id;
             $this->template->startChars = StringUtils::getChars();
             $this->template->startChar = null;
             $this->template->photos = null;
             $this->template->firstLoad = true;
             $this->template->photoPreview = null;
             $this->template->photoMessage = "";
             $this->template->editPhoto = null;
             $this->setDefaultValuesToAddArticleForm($editArticle);
         } catch (EntityNotFoundException $ex) {
             \Tracy\Debugger::log($ex);
             $this->flashMessage("Požadovaný článek nebyl nalezen.", "alert-error");
             $this->redirect("Articles:default");
         }
     } else {
         $this->template->tags = $tags;
         try {
             $this->template->choosenPhoto = $this->photoFacade->findOneById($photoId);
             $this->template->photoId = $photoId;
         } catch (EntityNotFoundException $ex) {
             \Tracy\Debugger::log($ex);
             $this->template->photoId = 0;
         }
     }
 }