Exemplo n.º 1
0
 private function toEntity(DbEntry $article)
 {
     return ArticleService::loadFromDb($article);
 }
Exemplo n.º 2
0
 private function formValuesToEntity(Form $form)
 {
     $values = (object) $form->getHttpData();
     $user = UserService::loadFromSession($form->getPresenter()->getUser());
     $photo = PhotoService::loadForArticle($values->photoId);
     $tags = new TagCollection();
     foreach ($values->tagList as $tag) {
         $tags->addItem(TagService::create($tag));
     }
     $categories = new CategoryCollection();
     foreach ($values->categories as $categoryId) {
         $categories->addItem(CategoryService::loadForArticle($categoryId));
     }
     $articleId = $form->getPresenter()->getParameter("articleId");
     if ($articleId) {
         return ArticleService::loadForUpdate($articleId, $values, $user, $photo, $tags, $categories);
     } else {
         return ArticleService::create($values, $user, $photo, $tags, $categories);
     }
 }