public function get() { $route = array('_links' => array("self" => array("href" => $this->rootUrl), "ea:login" => array('href' => $this->rootUrl . '/api/login'), "ea:user" => array('href' => $this->rootUrl . '/api/user/{id}'), "ea:student" => array('href' => $this->rootUrl . '/api/students'))); $json = \q::z()->arrayToJSON($route); return Response::make($json, '200')->header('Content-Type', 'application/hal+json'); }
function get($module, $access = NULL) { $result = $this->context->apiRoute; if (empty($access)) { return $result[$module]; } else { $resultEnum = \q::enum($result[$module]); return $resultEnum->where(function ($k) use($access) { return \q::enum($access)->contains($k['link']['rel']); })->val(); } }
<textarea rows="10" cols="50"> <?php echo q::z()->arrayToSimpleXml(q::apiRoute()->get(''))->asXML(); ?> </textarea>
public function findByName($name) { return User::where(q::username($name)); }
<textarea rows="10" cols="50"> <?php echo q::z()->arrayToSimpleXml(q::apiRoute()->get('user', array('login')))->asXML(); ?> </textarea>
public static function apiRoute() { return new \lib\ApiRoute(q::context()); }
public function relationMany() { $u = User::where(q::id(1)); $this->assertEquals(SalamaSuite::$users[0], $u->username); $this->assertEquals($u->comments[0]->pub_date, 0); $this->assertEquals($u->comments[0]->user_id, $u->id); $this->assertEquals($u->username, $name); $this->assertEquals($u->comments[1]->pub_date, 1); $this->assertEquals($u->comments[1]->user_id, $u->id); foreach ($u->comments as $k => $v) { $this->assertEquals($v->pub_date, $k); $this->assertEquals($v->user_id, $u->id); } $this->assertEquals(count($u->comments), 2); }