protected function __construct($params) { $this->params = $params; $this->fb = Services\FacebookAPI::getInstance(); $this->db = Services\DataBase::getInstance(); $this->db->connectOrCreate(); }
protected function __construct($params) { if (!isset($params["action"])) { throw new \Exception('param Action missing'); } $this->db = Services\DataBase::getInstance(); $this->db->connectOrCreate(); $user = Services\FacebookAPI::getInstance()->getUser(); if (preg_match("#^admin\\_#", $params["action"])) { if ($user && $user->isAdmin()) { $this->adminAction($params); return; } else { echo json_encode(["html" => ""]); return; } } if (is_callable([$this, $params["action"]])) { $this->{$params}["action"]($params); } }
static function getAll($limit = null) { $db = Services\DataBase::getInstance(); $table = $db->getPrefix() . strtolower((new \ReflectionClass(get_called_class()))->getShortName()); return $db->exec('SELECT * FROM ' . $table . ($limit ? " LIMIT {$limit}" : "")); }