コード例 #1
0
ファイル: Entity.php プロジェクト: floxim/floxim
 protected function beforeSave()
 {
     parent::beforeSave();
     unset($this['is_stub']);
     if (!$this['priority'] && $this['layout_id']) {
         $last_vis = fx::data('infoblock_visual')->where('layout_id', $this['layout_id'])->where('area', $this['area'])->order(null)->order('priority', 'desc')->one();
         $this['priority'] = $last_vis['priority'] + 1;
     }
     if ($this->needRecountFiles) {
         $this->recountFiles();
     }
 }
コード例 #2
0
ファイル: Entity.php プロジェクト: floxim/floxim
 protected function beforeSave()
 {
     $modified = $this->getModified();
     foreach ($modified as $field_keyword) {
         $field = $this->getField($field_keyword);
         if (!$field instanceof \Floxim\Floxim\Field\File) {
             continue;
         }
         $new_val = $this[$field_keyword];
         if (!is_string($new_val) || !preg_match("~^https?://~", $new_val)) {
             continue;
         }
         $file = fx::files()->saveRemoteFile($new_val, 'upload');
         if (!$file) {
             continue;
         }
         $field->setValue($file);
         $this[$field_keyword] = $field->getSavestring($this);
     }
     return parent::beforeSave();
 }