protected ForumManager::lastVisit($nid, AccountInterface $account)
Gets the last time the user viewed a node.
Parameters
int $nid: The node ID.
\Drupal\Core\Session\AccountInterface $account: Account to fetch last time for.
Return value
int The timestamp when the user last viewed this node, if the user has previously viewed the node; otherwise HISTORY_READ_LIMIT.
File
- core/modules/forum/src/ForumManager.php, line 309
Class
- ForumManager
- Provides forum manager service.
Namespace
Drupal\forum
Code
1 2 3 4 5 6 7 8 9 10 11 12 | protected function lastVisit( $nid , AccountInterface $account ) { if ( empty ( $this ->history[ $nid ])) { $result = $this ->connection->select( 'history' , 'h' ) ->fields( 'h' , array ( 'nid' , 'timestamp' )) ->condition( 'uid' , $account ->id()) ->execute(); foreach ( $result as $t ) { $this ->history[ $t ->nid] = $t ->timestamp > HISTORY_READ_LIMIT ? $t ->timestamp : HISTORY_READ_LIMIT; } } return isset( $this ->history[ $nid ]) ? $this ->history[ $nid ] : HISTORY_READ_LIMIT; } |
Please login to continue.