/** * Handles HTTP GET /Links/Count requests. * Get available links count. * * Renders JSON response in following format: * `{ * count: count * }` */ public function countAction() { //disable view rendering, we render JSON $this->view->setRenderLevel(View::LEVEL_NO_RENDER); //get links count $count = $this->_linksRepo->CountAllLinks(); $this->sendJsonResponse(["count" => $count]); }
/** * Handles HTTP GET /Nodes/Count requests. * Get available nodes count. * * Renders JSON response in following format: * `{ * count: count * }` */ public function countAction() { //disable view rendering, we render JSON $this->view->setRenderLevel(View::LEVEL_NO_RENDER); //get count from repository $count = $this->_nodesRepo->CountAllNodes(); $this->sendJsonResponse(["count" => $count]); }
/** * GET /Graph/status * * Get application status JSON containing status of application and counts of nodes, links. * JSON format: * `{ * works: true/false, * counts: { * nodes: n_nodes, * links: n_links * } * }` * @return void */ public function getStatusAction() { //disable view rendering $this->view->setRenderLevel(View::LEVEL_NO_RENDER); //get nodes count $node_count = $this->_nodesRepo->CountAllNodes(); //get links count $link_count = ceil($this->_linksRepo->CountAllLinks() / 2); //send JSON status response return $this->sendJsonResponse(array("works" => true, "counts" => array("nodes" => $node_count, "links" => $link_count))); }