public function __construct($id, $interface = array())
 {
     global $allInterfaceObjects;
     // from Generics.php
     if (empty($interface)) {
         $interface = $allInterfaceObjects[$id];
     }
     // if no $interface is provided, use toplevel interfaces from $allInterfaceObjects
     // Check if interface exists
     if (empty($interface['id'])) {
         throw new Exception("Interface '{$id}' does not exists", 500);
     }
     // Set attributes of interface
     $this->id = $interface['id'];
     $this->label = $interface['label'];
     $this->interfaceRoles = $interface['interfaceRoles'];
     $this->editableConcepts = (array) $interface['editableConcepts'];
     $this->invariantConjuctsIds = $interface['invConjunctIds'];
     // only applicable for Top-level interfaces
     $this->signalConjunctsIds = $interface['sigConjunctIds'];
     // only applicable for Top-level interfaces
     // CRUD rights
     $this->crudC = is_null($interface['crudC']) ? Config::get('defaultCrudC', 'transactions') : $interface['crudC'];
     $this->crudR = is_null($interface['crudR']) ? Config::get('defaultCrudR', 'transactions') : $interface['crudR'];
     $this->crudU = is_null($interface['crudU']) ? Config::get('defaultCrudU', 'transactions') : $interface['crudU'];
     $this->crudD = is_null($interface['crudD']) ? Config::get('defaultCrudD', 'transactions') : $interface['crudD'];
     // Information about the (editable) relation if applicable
     $this->relation = $interface['relation'];
     $this->relationIsFlipped = $interface['relationIsFlipped'];
     $this->editable = empty($interface['relation']) ? false : $interface['relationIsEditable'];
     $this->totaal = $interface['exprIsTot'];
     $this->univalent = $interface['exprIsUni'];
     $this->isProperty = $interface['exprIsProp'];
     $this->isIdent = $interface['exprIsIdent'];
     $this->srcConcept = $interface['srcConcept'];
     $this->tgtConcept = $interface['tgtConcept'];
     isset($interface['viewId']) ? $this->viewId = $interface['viewId'] : null;
     // Determine if tgtConcept is Object (true) or Scalar (false)
     $this->tgtConceptIsObject = Concept::getTypeRepresentation($this->tgtConcept) == "OBJECT" ? true : false;
     // Set attributes
     $this->refInterfaceId = $interface['refSubInterfaceId'];
     $this->isLinkTo = $interface['isLinkTo'];
     $this->boxSubInterfaces = $interface['boxSubInterfaces'];
     $this->expressionSQL = $interface['expressionSQL'];
     // Determine subInterfaces
     foreach ((array) $this->boxSubInterfaces as $subInterface) {
         $this->subInterfaces[] = new InterfaceObject($subInterface['id'], $subInterface);
     }
 }
 public function typeConversion($value, $concept)
 {
     switch (Concept::getTypeRepresentation($concept)) {
         case "DATE":
             $datetime = new DateTime($value);
             return $datetime->format('Y-m-d');
             // format to store in database
         // format to store in database
         case "DATETIME":
             $datetime = new DateTime($value);
             // $value can include timezone, e.g. 2005-08-15T15:52:01+00:00 (DATE_ATOM format)
             $datetime->setTimezone(new DateTimeZone('UTC'));
             // convert to UTC to store in database
             return $datetime->format('Y-m-d H:i:s');
             // format to store in database (UTC)
         // format to store in database (UTC)
         case "INTEGER":
             return (int) $value;
         case "BOOLEAN":
             return (bool) $value;
         case "DECIMAL":
             return (double) $value;
         default:
             return $value;
     }
 }
Exemple #3
0
 public function typeConversion($value, $concept)
 {
     switch (Concept::getTypeRepresentation($concept)) {
         case "DATE":
             $datetime = new DateTime($value);
             return $datetime->format('Y-m-d');
             // format in ISO-8601 standard
         // format in ISO-8601 standard
         case "DATETIME":
             $datetime = new DateTime($value, new DateTimeZone('UTC'));
             // datetimes are stored in UTC in database
             $datetime->setTimezone(new DateTimeZone(date_default_timezone_get()));
             // convert back to systemtime
             return $datetime->format(DateTime::ATOM);
             // format in ISO-8601 standard, i.e. 2005-08-15T15:52:01+00:00 (DateTime::ATOM)
         // format in ISO-8601 standard, i.e. 2005-08-15T15:52:01+00:00 (DateTime::ATOM)
         case "INTEGER":
             return (int) $value;
         case "BOOLEAN":
             return (bool) $value;
         case "DECIMAL":
             return (double) $value;
         default:
             return $value;
     }
 }