示例#1
0
 /**
  * {@inheritdoc}
  */
 public function createIndex(NodeInterface $node)
 {
     $query = $this->database->insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
     foreach ($node->getTranslationLanguages() as $langcode => $language) {
         $translation = $node->getTranslation($langcode);
         foreach ($translation->taxonomy_forums as $item) {
             $query->values(array('nid' => $node->id(), 'title' => $translation->label(), 'tid' => $item->target_id, 'sticky' => (int) $node->isSticky(), 'created' => $node->getCreatedTime(), 'comment_count' => 0, 'last_comment_timestamp' => $node->getCreatedTime()));
         }
     }
     $query->execute();
     // The logic for determining last_comment_count is fairly complex, so
     // update the index too.
     if ($node->isNew()) {
         $this->updateIndex($node);
     }
 }