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