Exemplo n.º 1
0
 public function create($data = array())
 {
     $obj = parent::create($data);
     $obj['created'] = date("Y-m-d H:i:s");
     $obj['priority'] = $this->nextPriority();
     return $obj;
 }
Exemplo n.º 2
0
 /**
  * Create new content entity
  * @param array $data Initial params
  * @return New content entity (not saved yet, without ID)
  */
 public function create($data = array())
 {
     $obj = parent::create($data);
     $component = fx::component($this->component_id);
     $obj['created'] = date("Y-m-d H:i:s");
     if ($component['keyword'] != 'floxim.user.user' && ($user = fx::env()->getUser())) {
         $obj['user_id'] = $user['id'];
     }
     $obj['type'] = $component['keyword'];
     if (!isset($data['site_id'])) {
         $obj['site_id'] = fx::env('site')->get('id');
     }
     $fields = $component->getAllFields()->find('default', '', System\Collection::FILTER_NEQ);
     foreach ($fields as $f) {
         if ($f['default'] === 'null') {
             continue;
         }
         if (!isset($data[$f['keyword']])) {
             if ($f['type'] == Field\Entity::FIELD_DATETIME) {
                 $obj[$f['keyword']] = date('Y-m-d H:i:s');
             } else {
                 $obj[$f['keyword']] = $f['default'];
             }
         }
     }
     return $obj;
 }