Exemplo n.º 1
0
 public function renderJSON()
 {
     $field = Type::Field($this->field);
     $result = [];
     if (!empty($this->value)) {
         $fieldBean = $field->getBean();
         $linkedSetId = $fieldBean->{$field->_('linkedSetId')};
         if (!empty($linkedSetId)) {
             $record = Set::byID($linkedSetId)->getRecord($this->value);
             //TODO: implement
             throw new \Exception('Not yet implemented');
         }
     }
     return '';
 }
Exemplo n.º 2
0
 public static function receive()
 {
     $slim = new Slim();
     $skemaKeys = $slim->request->get('skema');
     $sets = [];
     foreach ($skemaKeys as $skemaKey => $records) {
         if (!isset($sets[$skemaKey])) {
             if (is_numeric($skemaKey)) {
                 $id = $skemaKey;
                 $sets[$skemaKey] = Set::byID($id);
             } else {
                 $cleanName = $skemaKey;
                 $sets[$skemaKey] = Set::byCleanName($cleanName);
             }
         }
         $set = Type::Set($sets[$skemaKey]);
         foreach ($records as $recordID => $fields) {
             $recordChanged = false;
             $record = $set->getRecord($recordID);
             foreach ($fields as $fieldKey => $fieldValue) {
                 if (is_numeric($fieldKey)) {
                     $id = $fieldKey;
                     $field = $set->fieldsByID[$id];
                 } else {
                     $cleanName = $fieldKey;
                     $field = $set->fieldsByCleanName[$cleanName];
                 }
                 $directive = $field->getDirective();
                 $sanitized = $directive::sanitize($fieldValue);
                 if ($record->{$field->cleanName} !== $sanitized) {
                     $record->{$field->cleanName} = $sanitized;
                     $recordChanged = true;
                 }
             }
             if ($recordChanged) {
                 $record->update();
             }
         }
     }
 }
Exemplo n.º 3
0
Arquivo: Set.php Projeto: skema/skema
 public function eachJSON($fn)
 {
     $this->each($fn, function ($directive) {
         $result = Type::Directive($directive)->renderJSON();
         return $result;
     });
     return $this;
 }