HeartbeatSelectExtender.php 718 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. use Drupal\Core\Database\Query\SelectExtender;
  3. /**
  4. * Created by IntelliJ IDEA.
  5. * User: logicp
  6. * Date: 5/28/17
  7. * Time: 1:41 PM
  8. */
  9. class HeartbeatSelectExtender extends SelectExtender {
  10. public $lastActivityId = 0;
  11. /**
  12. * Sets the last id
  13. */
  14. public function setLastActivityId($lastActivityId) {
  15. $this->lastActivityId = $lastActivityId;
  16. $this->query->condition('h.id', $this->lastActivityId, '>');
  17. }
  18. /**
  19. * Sets the offset timestamps.
  20. */
  21. public function setOffsetTime($before, $after = 0) {
  22. $this->query->condition('ha.timestamp', $before, '<');
  23. if ($after > 0) {
  24. $this->query->condition('ha.timestamp', $_SERVER['REQUEST_TIME'] - $after, '>');
  25. }
  26. }
  27. }