public static function factory(myDoctrineRecord $record, $local, $alias, $required) { /* * Check first is local column has a value * not to modify the record */ if ($record->get($local)) { $media = $record->get($alias); } else { $media = new DmMedia(); $media->set('dm_media_folder_id', $record->getDmMediaFolder()->get('id')); } $form = new self($media); $form->configureRequired($required); $form->setRecord($record); return $form; }
/** * @return DmMedia the new media with $toMedia values */ public function copyTo(DmMedia $toMedia) { $toMedia->set('file', $this->get('file')); if (!copy($this->getFullPath(), $toMedia->getFullPath())) { throw new dmException(sprintf('Can not copy from %s to %s', $this->getFullPath(), $toMedia->getFullPath())); } $toMedia->fromArray(array('legend' => $this->get('legend'), 'author' => $this->get('author'), 'license' => $this->get('license'), 'mime' => $this->get('mime'), 'dimensions' => $this->get('dimensions'))); return $toMedia; }