Пример #1
0
 public function create(Entity $entity)
 {
     $record = array_filter($this->json_transcoder->encode($entity->asArray(), $this->json_properties));
     $record['created'] = time();
     $record['search'] = (int) $this->savedSearch;
     return $this->executeInsert($this->removeNullValues($record));
 }
Пример #2
0
 public function create(Entity $entity)
 {
     // Get record and filter empty values
     $record = array_filter($entity->asArray());
     // Set the created time
     $record['created'] = time();
     // And save if this is a saved search or collection
     $record['search'] = (int) $this->savedSearch;
     // Finally, save the record to the DB
     return $this->executeInsert($this->removeNullValues($record));
 }
Пример #3
0
 protected function verifyValid(Entity $entity)
 {
     $changed = $entity->getChanged();
     // Always pass values to validation
     if (isset($entity->values)) {
         $changed['values'] = $entity->values;
     }
     if (!$this->validator->check($changed, $entity->asArray())) {
         $this->validatorError($entity);
     }
 }
Пример #4
0
 public function create(Entity $entity)
 {
     $record = $entity->asArray();
     unset($record['form_id']);
     try {
         $uuid = Uuid::uuid4();
         $record['key'] = $uuid->toString();
     } catch (UnsatisfiedDependencyException $e) {
         Kohana::$log->add(Log::ERROR, $e->getMessage());
     }
     return $this->executeInsertAttribute($this->removeNullValues($record));
 }
Пример #5
0
 public function create(Entity $entity)
 {
     $role = $entity->asArray();
     // Remove permissions
     unset($role['permissions']);
     // Create role
     $id = $this->executeInsert($this->removeNullValues($role));
     if ($entity->permissions) {
         $this->updatePermissions($entity->name, $entity->permissions);
     }
     return $id;
 }
Пример #6
0
 public function create(Entity $entity)
 {
     $post = $entity->asArray();
     $post['created'] = time();
     // Remove attribute values and tags
     unset($post['values'], $post['tags'], $post['completed_stages']);
     // Create the post
     $id = $this->executeInsert($this->removeNullValues($post));
     if ($entity->tags) {
         // Update post-tags
         $this->updatePostTags($id, $entity->tags);
     }
     if ($entity->values) {
         // Update post-values
         $this->updatePostValues($id, $entity->values);
     }
     if ($entity->completed_stages) {
         // Update post-stages
         $this->updatePostStages($id, $entity->form_id, $entity->completed_stages);
     }
     return $id;
 }
Пример #7
0
 public function create(Entity $entity)
 {
     $record = $entity->asArray();
     unset($record['form_id']);
     return $this->executeInsert($this->removeNullValues($record));
 }
Пример #8
0
 protected function verifyValid(Entity $entity)
 {
     if (!$this->validator->check($entity->asArray())) {
         $this->validatorError($entity);
     }
 }
Пример #9
0
 public function create(Entity $entity)
 {
     $record = array_filter($entity->asArray());
     $record['created'] = time();
     return $this->executeInsert($this->removeNullValues($record));
 }
Пример #10
0
 protected function verifyValidContact(Entity $contact)
 {
     // validate contact
     if (!$this->contactValidator->check($contact->asArray())) {
         $this->contactValidatorError($contact);
     }
 }
Пример #11
0
 public function create(Entity $entity)
 {
     return $this->executeInsert($this->removeNullValues($entity->asArray()));
 }
Пример #12
0
 public function create(Entity $entity)
 {
     $record = $this->json_transcoder->encode($entity->asArray(), $this->json_properties);
     unset($record['form_id']);
     return $this->executeInsert($this->removeNullValues($record));
 }
Пример #13
0
 public function create(Entity $entity)
 {
     $post = $entity->asArray();
     $post['created'] = time();
     // Remove attribute values and tags
     unset($post['values'], $post['tags'], $post['completed_stages'], $post['sets'], $post['source'], $post['color']);
     // Set default value for post_date
     if (empty($post['post_date'])) {
         $post['post_date'] = date_create()->format("Y-m-d H:i:s");
         // Convert post_date to mysql format
     } else {
         $post['post_date'] = $post['post_date']->format("Y-m-d H:i:s");
     }
     // Create the post
     $id = $this->executeInsert($this->removeNullValues($post));
     if ($entity->tags) {
         // Update post-tags
         $this->updatePostTags($id, $entity->tags);
     }
     if ($entity->values) {
         // Update post-values
         $this->updatePostValues($id, $entity->values);
     }
     if ($entity->completed_stages) {
         // Update post-stages
         $this->updatePostStages($id, $entity->form_id, $entity->completed_stages);
     }
     return $id;
 }