예제 #1
0
 public static function getAllAtomObjects($concept)
 {
     foreach (Concept::getAllAtomIds($concept) as $tgtAtomId) {
         $tgtAtom = new Atom($tgtAtomId, $concept);
         $arr[] = $tgtAtom->getAtom();
     }
     return $arr;
 }
예제 #2
0
 /**
  * @url GET resource/{concept}/{atomId}
  * @param string $concept
  * @param string $atomId
  * @param array $roleIds
  */
 public function getConceptAtom($concept, $atomId, $roleIds = null)
 {
     try {
         $session = Session::singleton();
         $session->activateRoles($roleIds);
         if (!in_array($concept, $session->getEditableConcepts())) {
             throw new Exception("You do not have access for this call", 403);
         }
         $atom = new Atom($atomId, $concept);
         if (!$atom->atomExists()) {
             throw new Exception("Resource '{$atomId}' not found", 404);
         }
         return $atom->getAtom();
     } catch (Exception $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     }
 }
예제 #3
0
 /**
  * @url GET resource/{concept}/{atomId}
  */
 public function getConceptAtom($concept, $atomId)
 {
     try {
         // If login is enabled, check if users may request all atoms.
         if (Config::get('loginEnabled')) {
             $editableConcepts = array();
             $roles = Role::getAllSessionRoles();
             foreach ($roles as $role) {
                 $editableConcepts = array_merge($editableConcepts, $role->editableConcepts);
             }
             if (!in_array($concept, $editableConcepts)) {
                 throw new Exception("You do not have access for this call", 403);
             }
         }
         $atom = new Atom($atomId, $concept);
         if (!$atom->atomExists()) {
             throw new Exception("Resource '{$atomId}' not found", 404);
         }
         return $atom->getAtom();
     } catch (Exception $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     }
 }