Example #1
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);
     });
 }