/** @return string */ public function prepareQuery($query, $args = null, $isInternalCall = false) { if (!is_array($args)) { $args = array($args); } $query = StringTools::parse($query, array_merge($this->globalQueryArgs, $args), array($this, 'prepareQueryFilterCallback')); if ($isInternalCall) { Database::$countQueries++; $this->countQueries++; if ($this->_backupLastQuery) { $this->_lastQuery = $query; } if ($this->debug && $this->events) { $this->events->trigger('log', '[' . $this->id . '] Query: ' . $query); } } return $query; }
public function getAppTool($tool) { $t = $this->_tools->get($tool); if ($t) { return $t; } if (method_exists($this, $tool)) { return $this->{$tool}(); } $event = $this->events->trigger($tool); if ($event->data) { $this->_tools->set($tool, $event->data); return $event->data; } return null; }
public function emergencyShutdown($reason) { if ($this->_emergencyShutdownInProgress) { return; } $this->_emergencyShutdownInProgress = true; $this->events->trigger('emergencyShutdown'); if ($this->currentTask) { /** @var $response Response */ $this->currentTask->page->parseError(ResponseCode::CODE_500, $reason); } $this->destroy(); if ($this->onEmergencyShutdown) { call_user_func($this->onEmergencyShutdown, $this); } else { if ($this->currentTask) { $this->currentTask->response->postHeaders(); echo $this->currentTask->response->content; } exit; } }