public function getAsset() { if ($this->asset === null) { $this->asset = AssetFacade::find($this->attrs['asset_id']); } return $this->asset; }
/** * Returns the associated asset. * * @return AssetContract */ public function getAsset() { if ($this->asset === null) { $this->asset = AssetFacade::find($this->getAssetId()); } return $this->asset; }
public function __construct(Page $page, array $attrs, $slotname, $editable = true) { parent::__construct($page, $attrs, $slotname, $editable); if (isset($attrs['asset_id'])) { $this->asset = AssetFacade::find($this->attrs['asset_id']); } }
public function download() { $assets = AssetFacade::find($this->request->input('assets')); if (count($assets) === 1) { return Response::download($assets[0]->getFilename(), $assets[0]->getOriginalFilename()); } $downloadFilename = rtrim($this->request->input('filename'), '.zip') . '.zip'; $filename = tempnam(sys_get_temp_dir(), 'boomcms_asset_download'); $zip = new ZipArchive(); $zip->open($filename, ZipArchive::CREATE); foreach ($assets as $asset) { $zip->addFile($asset->getFilename(), $asset->getOriginalFilename()); } $zip->close(); $response = Response::make()->header('Content-type', 'application/zip')->header('Content-Disposition', "attachment; filename={$downloadFilename}")->setContent(file_get_contents($filename)); unlink($filename); return $response; }
/** * @param Request $request * @param Asset $asset */ public function update(Request $request, Asset $asset, Site $site) { $this->authorize('manageAssets', $site); $asset->setTitle($request->input(Asset::ATTR_TITLE))->setDescription($request->input(Asset::ATTR_DESCRIPTION))->setCredits($request->input(Asset::ATTR_CREDITS))->setThumbnailAssetId($request->input(Asset::ATTR_THUMBNAIL_ID)); AssetFacade::save($asset); return $this->show($asset); }
public function upload() { $assetIds = []; list($validFiles, $errors) = $this->validateFileUpload(); foreach ($validFiles as $file) { $asset = new Asset(); $asset->setUploadedTime(new DateTime('now'))->setUploadedBy(Auth::getPerson())->setTitle($file->getClientOriginalName())->setType(AssetHelper::typeFromMimetype($file->getMimeType())); $assetIds[] = AssetFacade::save($asset)->getId(); AssetFacade::createVersionFromFile($asset, $file); } return count($errors) ? new JsonResponse($errors, 500) : $assetIds; }