public function map(EntityContract $entity, array $data) { $id = $data['post_parent']; $entity->setParent(function () use($id) { $parent = null; if ($id) { $parent = $this->postRepository->postOfId($id); } return $parent; }); $id = $data['ID']; $entity->setCategories(function () use($id) { $categories = new Collection(); foreach (wp_get_post_categories($id) as $termId) { $categories->push($this->categoryRepository->categoryOfId($termId)); } return $categories; }); $entity->setTags(function () use($id) { $tags = new Collection(); foreach (wp_get_post_tags($id) as $termId) { $tags->push($this->tagRepository->tagOfId($termId)); } return $tags; }); }
public function map(EntityContract $entity, array $data) { $entity->setParentId($id = $data['post_parent']); $entity->setParent(function () use($id) { $parent = null; if ($id) { $parent = $this->pageRepository->pageOfId($id); } return $parent; }); }
public function map(EntityContract $entity, array $data) { $entity->setPosts(function () use($data) { return $this->postRepository->postsTagged($data['term_id']); }); $entity->setParent(function () use($data) { $parent = null; if ($data['parent']) { $parent = $this->tagRepository->tagOfId($data['parent']); } return $parent; }); }
public function map(EntityContract $entity, array $data) { $entity->init((object) $data); $id = $data['ID']; $entity->setPosts(function () use($id) { return $this->postRepository->postsByAuthor($id); }); $entity->setPages(function () use($id) { return $this->pageRepository->pagesByAuthor($id); }); $entity->setComments(function () use($id) { return $this->commentRepository->commentsByAuthor($id); }); }
public function map(EntityContract $entity, array $data) { $entity->setPosts(function () use($data) { return $this->postRepository->postsInCategory($data['term_id']); }); $id = $data['parent']; $entity->setParentId($id); $entity->setParent(function () use($id) { $parent = null; if ($id) { $parent = $this->categoryRepository->categoryOfId($id); } return $parent; }); }
public function map(EntityContract $entity, array $data) { $entity->setId($data['term_id']); $entity->setName($data['name']); $entity->setSlug($data['slug']); $entity->setDescription($data['description']); $entity->setCount($data['count']); // Relationships $entity->setTaxonomy(get_taxonomy($data['taxonomy'])); $entity->setNative($data); }
public function map(EntityContract $entity, array $data) { $entity->setMimeType($data['post_mime_type']); }
public function map(EntityContract $entity, array $data) { $entity->setId($data['ID']); $entity->setDate($data['post_date']); $entity->setContent($data['post_content']); $entity->setTitle($data['post_title']); $entity->setExcerpt($data['post_excerpt']); $entity->setStatus($data['post_status']); $entity->setCommentStatus($data['comment_status']); $entity->setPingStatus($data['ping_status']); $entity->setPassword($data['post_password']); $entity->setSlug($data['post_name']); $entity->setModified($data['post_modified']); $entity->setMenuOrder($data['menu_order']); $entity->setType($data['post_type']); $entity->setNative($data); // Relations $entity->setAuthorId($id = $data['post_author']); $entity->setAuthor(function () use($id) { return $this->userRepository->userOfId($id); }); $id = $data['ID']; $entity->setFeaturedImage(function () use($id) { $upload = null; if ($uId = get_post_thumbnail_id($id)) { $upload = $this->uploadRepository->uploadOfId($uId); } return $upload; }); if ($this->commentRepository) { $entity->setComments(function () use($id) { return $this->commentRepository->commentsForPost($id); }); } }
public function map(EntityContract $entity, array $data) { $entity->setId($data['comment_ID']); $entity->setPostId($id = $data['comment_post_ID']); $entity->setPost(function () use($id) { return $this->postRepository->postOfId($id); }); $entity->setAuthorName($data['comment_author']); $entity->setAuthorEmail($data['comment_author_email']); $entity->setAuthorUrl($data['comment_author_url']); $entity->setAuthorIp($data['comment_author_IP']); $entity->setDate($data['comment_date']); $entity->setContent($data['comment_content']); $entity->setStatus($data['comment_approved']); $entity->setUserAgent($data['comment_agent']); $entity->setType($data['comment_type']); $entity->setParentId($id = $data['comment_parent']); $entity->setParent(function () use($id) { $parent = null; if ($id) { $parent = $this->commentRepository->commentOfId($id); } return $parent; }); $entity->setUserId($id = $data['user_id']); $entity->setUser(function () use($id) { $user = null; if ($id) { $user = $this->userRepository->userOfId($id); } return $user; }); }