/** * media 객체로 반환 * * @param File $file file instance * @return Video * @throws NotAvailableException */ public function make(File $file) { if ($this->isAvailable($file->getMime()) !== true) { throw new NotAvailableException(); } if (!($meta = $this->repo->find($file->getId()))) { $meta = $this->extractInformation($file); $meta->dataEncode(Video::getJsonType()); $meta = $this->repo->insert($meta); } return $this->createModel($file, $meta); }
/** * 파일이 미디어 파일인지 확인 * * @param File $file file instance * @return bool */ public function is(File $file) { foreach ($this->handlers as $type => $handler) { if ($handler->isAvailable($file->getMime()) === true) { return true; } } return false; }
/** * media 객체로 반환 * * @param File $file file instance * @param array $addInfo additional information * @return Image * @throws NotAvailableException */ public function make(File $file, array $addInfo = []) { if ($this->isAvailable($file->getMime()) !== true) { throw new NotAvailableException(); } if (!($meta = $this->repo->find($file->getId()))) { $meta = $this->extractInformation($file); foreach ($addInfo as $key => $value) { $meta->{$key} = $value; } $meta = $this->repo->insert($meta); } return $this->createModel($file, $meta); }