forum_node_update(EntityInterface $node)
Implements hook_ENTITY_TYPE_update() for node entities.
File
- core/modules/forum/forum.module, line 171
- Provides discussion forums.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | function forum_node_update(EntityInterface $node ) { if (\Drupal::service( 'forum_manager' )->checkNodeType( $node )) { // If this is not a new revision and does exist, update the forum record, // otherwise insert a new one. /** @var \Drupal\forum\ForumIndexStorageInterface $forum_index_storage */ $forum_index_storage = \Drupal::service( 'forum.index_storage' ); if ( $node ->getRevisionId() == $node ->original->getRevisionId() && $forum_index_storage ->getOriginalTermId( $node )) { if (! empty ( $node ->forum_tid)) { $forum_index_storage ->update( $node ); } // The node is removed from the forum. else { $forum_index_storage -> delete ( $node ); } } else { if (! empty ( $node ->forum_tid)) { $forum_index_storage ->create( $node ); } } // If the node has a shadow forum topic, update the record for this // revision. if (! empty ( $node ->shadow)) { $forum_index_storage ->deleteRevision( $node ); $forum_index_storage ->create( $node ); } // If the node is published, update the forum index. if ( $node ->isPublished()) { $forum_index_storage ->deleteIndex( $node ); $forum_index_storage ->createIndex( $node ); } // When a forum node is unpublished, remove it from the forum_index table. else { $forum_index_storage ->deleteIndex( $node ); } } } |
Please login to continue.