Beispiel #1
0
 /**
  * Constructor of role
  * Private function to prevent outside instantiation of roles. Use Role::getRoleById($roleId) or Role::getRoleByName($roleName)
  * 
  * @param array $roleDef
  */
 private function __construct($roleDef)
 {
     $this->id = $roleDef['id'];
     $this->label = $roleDef['name'];
     $this->maintains = $roleDef['maintains'];
     foreach ($roleDef['interfaces'] as $ifcId) {
         $this->interfaces[] = InterfaceObject::getInterface($ifcId);
     }
 }
    throw new Exception("Not implemented yet", 501);
});
$app->patch('/resources/:resourceType/:resourceId(/:ifcPath+)', function ($resourceType, $resourceId, $ifcPath = array()) use($app) {
    $session = Session::singleton();
    $roleIds = $app->request->params('roleIds');
    $topLevelIfcId = $app->request->params('topLevelIfc');
    $options = $app->request->params();
    $session->activateRoles($roleIds);
    if (empty($ifcPath) && empty($topLevelIfcId)) {
        throw new Exception("Parameter 'topLevelIfc' is required to return data when no interface path is specified", 400);
    }
    $ifcPath = implode('/', $ifcPath);
    $atom = new Atom($resourceId, Concept::getConcept($resourceType));
    $atom->topLevelIfcId = $topLevelIfcId;
    // Create atom if not exists and crudC is allowed
    if (!$atom->atomExists() && InterfaceObject::getInterface($topLevelIfcId)->crudC) {
        $atom->addAtom();
    }
    $atomOrIfc = $atom->walkIfcPath($ifcPath);
    // Perform patch(es)
    $content = $atomOrIfc->patch($app->request->getBody(), $options);
    // Return result
    $result = array('patches' => $app->request->getBody(), 'content' => $content, 'notifications' => Notifications::getAll(), 'invariantRulesHold' => $session->database->getInvariantRulesHold(), 'requestType' => $session->database->getRequestType(), 'sessionRefreshAdvice' => $session->getSessionRefreshAdvice());
    print json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
});
$app->post('/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);
Beispiel #3
0
 /**
  * 
  * @return InterfaceObject[]
  */
 public function getInterfaces()
 {
     $interfaces = array();
     foreach ($this->interfaceIds as $ifcId) {
         $ifc = InterfaceObject::getInterface($ifcId);
         $interfaces[$ifc->id] = $ifc;
     }
     return $interfaces;
 }
Beispiel #4
0
 /**
  * Chains this atom to an interface as srcAtom 
  * @param string $ifcId
  * @throws Exception
  * @return InterfaceObject
  */
 public function ifc($ifcId)
 {
     if (is_null($this->parentIfc)) {
         $ifc = InterfaceObject::getInterface($ifcId);
     } elseif ($this->parentIfc->isRef()) {
         $ifc = InterfaceObject::getInterface($ifcId);
     } else {
         $ifc = $this->parentIfc->getSubinterface($ifcId);
     }
     $clone = clone $ifc;
     $clone->setSrcAtom($this);
     return $clone;
 }