Example #1
0
 protected function addPostCategories(PostInterface $post)
 {
     foreach ($post->getCategories() as $cat) {
         if (!$cat instanceof CategoryInterface) {
             continue;
         }
         $data = Category::toArray($cat);
         $cat = $this->createCategory($data);
         $this->addCategory($cat);
     }
 }
Example #2
0
 protected function addPost(PostInterface $post)
 {
     if (!$post->getPublish()) {
         return;
     }
     $this->posts[$post->getKey()] = $post;
     usort($this->posts, function ($a, $b) {
         if (!$a instanceof PostInterface) {
             return 1;
         }
         if (!$b instanceof PostInterface) {
             return -1;
         }
         $ua = $a->getUpdated();
         $ub = $b->getUpdated();
         return $ua === $ub ? 0 : ($ua > $ub ? -1 : 1);
     });
 }