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->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; }); }
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->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; }); }