print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); }); $app->get('/resources/:resourceType/:resourceId', function ($resourceType, $resourceId) use($app) { $session = Session::singleton(); $roleIds = $app->request->params('roleIds'); $session->activateRoles($roleIds); $resource = new Atom($resourceId, Concept::getConcept($resourceType)); // Checks if (!$session->isEditableConcept($resource->concept)) { throw new Exception("You do not have access for this call", 403); } // Get specific resource (i.e. atom) if (!$resource->atomExists()) { throw new Exception("Resource '{$resource->__toString()}' not found", 404); } $content = $resource->getAtom(); print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); }); /************************************************************************************************** * * resource calls WITH interfaces * *************************************************************************************************/ $app->get('/resources/:resourceType/:resourceId/:ifcPath+', function ($resourceType, $resourceId, $ifcPath) use($app) { $session = Session::singleton(); $roleIds = $app->request->params('roleIds'); $session->activateRoles($roleIds); $options = $app->request->params(); $ifcPath = implode('/', $ifcPath); $atom = new Atom($resourceId, Concept::getConcept($resourceType)); $atomOrIfc = $atom->walkIfcPath($ifcPath);
/** * Return content of all atoms for this concept * @return mixed[] */ public function getAllAtomObjects() { // Query all atoms in table if (isset($this->def['allAtomsQuery'])) { $query = $this->def['allAtomsQuery']; } else { $firstCol = current($this->mysqlConceptTable->getCols()); // We can query an arbitrary concept col for checking the existence of an atom $query = "SELECT DISTINCT `{$firstCol->name}` as `atomId` FROM `{$this->mysqlConceptTable->name}` WHERE `{$firstCol->name}` IS NOT NULL"; } $arr = array(); foreach ((array) $this->database->Exe($query) as $row) { $tgtAtom = new Atom($row['atomId'], $this, null, $row); $arr[] = $tgtAtom->getAtom(); } return $arr; }