示例#1
0
 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;
     });
 }
示例#2
0
 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;
     });
 }
示例#3
0
 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);
     });
 }
示例#4
0
 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;
     });
 }
示例#5
0
文件: Request.php 项目: EMRL/fire
 /**
  * Set the current entities for use in templates
  */
 protected function setCurrentEntities()
 {
     global $wp_query;
     if ($post = $wp_query->post) {
         if ($post->post_type === PagePostType::TYPE) {
             $this->pageRepository->setCurrentPage($this->pageRepository->pageOfId($post->ID));
         } elseif ($post->post_type === PostPostType::TYPE) {
             $this->postRepository->setCurrentPost($this->postRepository->postOfId($post->ID));
         }
     }
     $collection = new Collection();
     if ($posts = $wp_query->posts) {
         foreach ($posts as $post) {
             $collection->push($this->postRepository->postOfId($post->ID));
         }
     }
     $this->postRepository->setCurrentPosts($collection);
 }