SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/DisplayConditions/Session/ThisPageviews.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. namespace Sprout\Helpers\DisplayConditions\Session;
  15.  
  16. use Sprout\Helpers\DisplayConditions\DisplayConditionInteger;
  17. use Sprout\Helpers\SessionStats;
  18. use Sprout\Helpers\Url;
  19.  
  20.  
  21. /**
  22.  * Display condtion for number of times this page has been viewed
  23.  */
  24. class ThisPageviews extends DisplayConditionInteger
  25. {
  26.  
  27. /**
  28.   * Return the current value of the variable
  29.   *
  30.   * @param array $env Environment, such as page id etc
  31.   * @return string
  32.   */
  33. protected function getCurrentValue(array $env)
  34. {
  35. $url = Url::current();
  36. return SessionStats::numPageviews($url);
  37. }
  38.  
  39. }
  40.