Ejemplo n.º 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;
     });
 }
Ejemplo n.º 2
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;
     });
 }