public function xGetListAction()
{
$this->request->defineParams(array('query', 'sort' => array('type' => 'json')));
$hist = new WebhookHistory();
$sql = "SELECT " . $hist->fields('h') . ", w.name AS webhookName, e.url\n FROM " . $hist->table() . " h\n INNER JOIN webhook_endpoints e ON h.endpoint_id = e.endpoint_id\n INNER JOIN webhook_configs w ON h.webhook_id = w.webhook_id\n WHERE e.env_id = ?\n AND :FILTER:\n ";
$args = array($this->getEnvironmentId());
if ($this->getParam('eventId')) {
$sql .= ' AND h.event_id = ?';
$args[] = $this->getParam('eventId');
}
$response = $this->buildResponseFromSql2($sql, array('created'), array('e.url', 'h.event_type'), $args);
foreach ($response['data'] as $index => $row) {
$hist = new WebhookHistory();
$hist->load($row);
$item = array();
foreach (get_object_vars($hist) as $k => $v) {
$item[$k] = $v;
}
$item['url'] = $row['url'];
$item['webhookName'] = $row['webhookName'];
$item['created'] = Scalr_Util_DateTime::convertTz($hist->created);
unset($hist);
$response['data'][$index] = $item;
}
$this->response->data($response);
}