Ejemplo n.º 1
0
 public static function loadFromDb(DbEntry $article)
 {
     $instance = new Article();
     $instance->setId($article->id);
     $instance->setTitle($article->title);
     $instance->setContent($article->content);
     $instance->setPublishedAt($article->published_at);
     if ($article->last_modified_at) {
         $instance->setLastModifiedAt($article->last_modified_at);
     }
     $instance->setDisplayed($article->displayed);
     $instance->setVisible($article->visible);
     $instance->setUrl($article->url);
     $instance->setUser(UserService::loadFromDb($article->user));
     $instance->setPhoto(PhotoService::loadFromDb($article->photo));
     $instance->setTags(self::loadTagsFromDb($article));
     $instance->setCategories(self::loadCategoriesFromDb($article));
     $instance->setComments(self::loadCommentsFromDb($article));
     return $instance;
 }
Ejemplo n.º 2
0
 private function formValuesToEntity(Form $form, $values)
 {
     $user = UserService::loadFromSession($form->getPresenter()->getUser());
     $tags = new TagCollection();
     foreach ($values->tagPhotoList as $tag) {
         $tags->addItem(TagService::create($tag));
     }
     if ($values->photoId == "0") {
         return PhotoService::create($values, $user, $tags);
     } else {
         return PhotoService::loadForUpdate($values->photoId, $values, $user, $tags);
     }
 }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
0
 private function toEntity(DbEntry $user)
 {
     return PhotoService::loadFromDb($user);
 }