Exemplo n.º 1
0
 /**
  * Return the controller to be used to display an asset.
  *
  * @param Asset $asset
  *
  * @return string
  */
 public static function controller(AssetModel $asset)
 {
     $namespace = 'BoomCMS\\Http\\Controllers\\ViewAsset\\';
     if (!$asset->getExtension()) {
         return;
     }
     $byExtension = $namespace . ucfirst($asset->getExtension());
     if (class_exists($byExtension)) {
         return $byExtension;
     }
     $byType = $namespace . ucfirst($asset->getType());
     if (class_exists($byType)) {
         return $byType;
     }
     return $namespace . 'BaseController';
 }
Exemplo n.º 2
0
 public function boot()
 {
     parent::boot();
     Models\Asset::observe(CreationLogObserver::class);
     Models\AssetVersion::observe(CreationLogObserver::class);
     Models\Page::observe(CreationLogObserver::class);
     Models\PageVersion::observe(CreationLogObserver::class);
     Models\Asset::observe(SetSiteObserver::class);
     Models\Group::observe(SetSiteObserver::class);
     Models\Page::observe(SetSiteObserver::class);
     Models\Tag::observe(SetSiteObserver::class);
     Models\URL::observe(SetSiteObserver::class);
     Models\Page::observe(DeletionLogObserver::class);
 }
Exemplo n.º 3
0
 /**
  * @param AssetModel $model
  *
  * @return AssetModel
  */
 public function save(AssetModel $model)
 {
     $model->save();
     return $model;
 }
Exemplo n.º 4
0
 public function testSetVersion()
 {
     $asset = new Asset();
     $version = new AssetVersion();
     $asset->setVersion($version);
     $this->assertEquals($version, $asset->getLatestVersion());
 }
Exemplo n.º 5
0
 /**
  * @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);
 }
Exemplo n.º 6
0
 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;
 }
 public function destroy(Request $request, Asset $asset = null)
 {
     $assetIds = $asset->getId() ? [$asset->getId()] : $request->input('assets');
     AssetFacade::delete($assetIds);
 }