getCurrentDateTime() public method

If you use this method for getting the current date and time everywhere in your code, it will be possible to simulate a certain time in unit tests or in the actual application (for realizing previews etc).
public getCurrentDateTime ( ) : DateTime
return DateTime The current date and time - or a simulated version of it
Ejemplo n.º 1
0
 /**
  * Tells if this node is "visible".
  *
  * For this the "hidden" flag and the "hiddenBeforeDateTime" and "hiddenAfterDateTime" dates are
  * taken into account.
  *
  * @return boolean
  * @api
  */
 public function isVisible()
 {
     if ($this->nodeData->isVisible() === false) {
         return false;
     }
     $currentDateTime = $this->context->getCurrentDateTime();
     if ($this->getHiddenBeforeDateTime() !== null && $this->getHiddenBeforeDateTime() > $currentDateTime) {
         return false;
     }
     if ($this->getHiddenAfterDateTime() !== null && $this->getHiddenAfterDateTime() < $currentDateTime) {
         return false;
     }
     return true;
 }