/**
  * Prepare datas before save
  *
  * @see \ContentinumComponents\Mapper\Process::save()
  */
 public function save($datas, $entity = null, $stage = '', $id = null)
 {
     $mcSerialize = new HandleSerializeDatabase();
     if (null === $entity->getPrimaryValue()) {
         $datas['settingsFormular'] = $mcSerialize->execSerialize($datas['settingsFormular']);
         parent::save($datas, $entity, $stage, $id);
     } else {
         $datas['settingsFormular'] = $mcSerialize->execSerialize($datas['settingsFormular']);
         parent::save($datas, $entity, $stage, $id);
     }
     unset($mcSerialize);
 }
 /**
  *
  * @param array $params
  * @param string $posts
  */
 public function processRequest(array $params = null, $posts = null)
 {
     if (is_array($posts)) {
         $params = array_merge($params, $posts);
     }
     if (isset($params['data']['ident'])) {
         $id = $params['data']['ident'];
         unset($params['data']['ident']);
     } else {
         return array('error' => 'miss_paramter');
     }
     try {
         switch ($params['app']['attribute']) {
             case 'file':
                 $mcSerialize = new HandleSerializeDatabase();
                 $this->save(array('mediaMetas' => $mcSerialize->execSerialize($params['data'])), $this->find($id));
                 return array('success' => true);
                 break;
             default:
                 break;
         }
     } catch (\Exception $e) {
         return array('error' => $e->getMessage());
     }
 }
 /**
  * Serialize group params if params avaiable
  * 
  * @param array $datas
  * @return string
  */
 public function serializeGroupParams($datas)
 {
     if (null === $this->mcSerialize) {
         $this->mcSerialize = new HandleSerializeDatabase();
     }
     return $this->mcSerialize->execSerialize($datas);
 }
 public function saveMetas($app, $datas)
 {
     $metas = array();
     foreach ($this->mediaAttributeFields as $field) {
         if (isset($datas[$field])) {
             $metas[$field] = $datas[$field];
         }
     }
     $mcSerialize = new HandleSerializeDatabase();
     $update['mediaMetas'] = $mcSerialize->execSerialize($metas);
     parent::save($update, $this->find($datas['ident']));
     return true;
 }
 /**
  * Database insert treatment
  *
  * @param array $datas
  * @return \Mcwork\Model\FsUpload
  */
 public function preparedInsert(array $datas)
 {
     $mcSerialize = new HandleSerializeDatabase();
     $this->addInsert('metaCoding', $mcSerialize::STD_METHOD);
     if (isset($this->insert['mediaAlternate'])) {
         $this->addInsert('mediaAlternate', $mcSerialize->execSerialize($this->insert['mediaAlternate']));
     } else {
         $this->addInsert('mediaAlternate', ' ');
     }
     $fields = array();
     $attribs = array();
     if (in_array($this->ext, $this->imageExtensions)) {
         $metas = array('alt' => $this->mediaName);
         $fields = $this->getMediaAttributeFields('images');
         $size = new Size($this->targetPathFileName);
         $size->imgSize();
         $attribs['dimensions'] = array('height' => $size->getHeight(), 'width' => $size->getWidth());
         $this->addInsert('mediaDimensions', $size->getWidth() . 'x' . $size->getHeight());
     } else {
         $metas = array('linkname' => $this->mediaName);
         $fields = $this->getMediaAttributeFields('files');
     }
     if (!empty($datas) && !empty($fields)) {
         foreach ($fields as $field) {
             if (isset($datas[$field])) {
                 $metas[$field] = $datas[$field];
             }
         }
     }
     if (!empty($attribs)) {
         $this->addInsert('mediaAttribute', $mcSerialize->execSerialize($attribs));
     }
     $this->addInsert('mediaMetas', $mcSerialize->execSerialize($metas));
     return $this;
 }