Ejemplo n.º 1
0
 /**
  * Update the page to be unpublished
  *
  * @param  Page   	$page Page to update as unpublished
  *
  * @return Page   	$page Updated Page object
  */
 public function unpublish(Page $page)
 {
     // Set the end time to now
     $end = new DateTimeImmutable();
     $start = $page->publishDateRange->getStart();
     // If the start date is in the new end time then set it to null
     if ($start && $start->getTimestamp() > $end->getTimestamp()) {
         $start = null;
     }
     // Set the new unpublsih date range
     $page->publishDateRange = new DateRange($start, $end);
     // Save the page to the DB
     $this->_savePublishData($page);
     // Return the updated Page object
     $this->_transaction->commit();
     return $page;
 }