Airship\Cabin\Bridge\Blueprint\Skyport::getLogMessages PHP Method

getLogMessages() public method

Get the recent messages in the update log
public getLogMessages ( DateTime $cutoffDate = null ) : array
$cutoffDate DateTime
return array
    public function getLogMessages(\DateTime $cutoffDate = null) : array
    {
        if (!$cutoffDate) {
            // Default: the past 24 hours
            $cutoffDate = (new \DateTime())->sub(new \DateInterval('P01D'));
        }
        $messages = $this->db->run("SELECT * FROM airship_continuum_log WHERE created > ? ORDER BY logid DESC", $cutoffDate->format('Y-m-d H:i:s'));
        if (empty($messages)) {
            return [];
        }
        foreach ($messages as $i => $msg) {
            $messages[$i]['context'] = \json_decode($msg['context'], true);
        }
        return $messages;
    }

Usage Example

Example #1
0
 /**
  * View the update log
  *
  * @route admin/skyport/log
  */
 public function viewLog()
 {
     /** @todo allow a more granular window of logged events to be viewed */
     $this->lens('skyport/log', ['active_link' => 'bridge-link-admin-ext-log', 'logged' => $this->skyport->getLogMessages()]);
 }