Added endpoints to CRUD presentation materials
* Videos ** get videos GET /api/v1/summits/{id}/presentations/{presentation_id}/videos required scopes %s/summits/read %s/summits/read/all ** create video POST /api/v1/summits/{id}/presentations/{presentation_id}/videos payload 'you_tube_id' => 'required|alpha_dash', 'name' => 'sometimes|required|text:512', 'description' => 'sometimes|required|text|max:512', 'featured' => 'sometimes|required|boolean', 'display_on_site' => 'sometimes|required|boolean' required scopes %s/summits/write-presentation-materials %s/summits/write-presentation-videos ** update video PUT /api/v1/summits/{id}/presentations/{presentation_id}/videos/{video_id} payload 'you_tube_id' => 'required|alpha_dash', 'name' => 'sometimes|required|text:512', 'description' => 'sometimes|required|text|max:512', 'featured' => 'sometimes|required|boolean', 'display_on_site' => 'sometimes|required|boolean' 'order' => 'sometimes|integer|min:1', required scopes %s/summits/write-presentation-materials %s/summits/write-presentation-videos ** delete video DELETE /api/v1/summits/{id}/presentations/{presentation_id}/videos/{video_id} required scopes %s/summits/write-presentation-materials %s/summits/write-presentation-videos * Slides ** get slides GET /api/v1/summits/{id}/presentations/{presentation_id}/slides required scopes %s/summits/read %s/summits/read/all ** create slide POST '/api/v1/summits/{id}/presentations/{presentation_id}/slides payload 'file' => 'required_without:link', 'link' => 'required_without:file|text:512', 'name' => 'required|text:512', 'description' => 'sometimes|required|text|max:512', 'display_on_site' => 'sometimes|required|boolean', 'featured' => 'sometimes|required|boolean', required scopes %s/summits/write-presentation-materials %s/summits/write-presentation-slides ** update slide PUT '/api/v1/summits/{id}/presentations/{presentation_id}/slides/{slide_id} payload 'file' => 'sometimes|require', 'link' => 'sometimes|required|text:512', 'name' => 'sometimes|required|text:512', 'description' => 'sometimes|required|text|max:512', 'display_on_site' => 'sometimes|required|boolean', 'featured' => 'sometimes|required|boolean', 'order' => 'sometimes|integer|min:1', required scopes %s/summits/write-presentation-materials %s/summits/write-presentation-slides ** delete slide DELETE '/api/v1/summits/{id}/presentations/{presentation_id}/slides/{slide_id} required scopes %s/summits/write-presentation-materials %s/summits/write-presentation-slides * Links ** get links GET /api/v1/summits/{id}/presentations/{presentation_id}/links required scopes %s/summits/read %s/summits/read/all ** create link POST '/api/v1/summits/{id}/presentations/{presentation_id}/links payload 'link' => 'required|text:512', 'name' => 'required|text:512', 'description' => 'sometimes|required|text|max:512', 'display_on_site' => 'sometimes|required|boolean', 'featured' => 'sometimes|required|boolean', required scopes %s/summits/write-presentation-materials %s/summits/write-presentation-links ** update link PUT '/api/v1/summits/{id}/presentations/{presentation_id}/links/{link_id} payload 'link' => 'sometimes|required|text:512', 'name' => 'sometimes|required|text:512', 'description' => 'sometimes|required|text|max:512', 'display_on_site' => 'sometimes|required|boolean', 'featured' => 'sometimes|required|boolean', 'order' => 'sometimes|integer|min:1', required scopes %s/summits/write-presentation-materials %s/summits/write-presentation-links ** delete links DELETE '/api/v1/summits/{id}/presentations/{presentation_id}/links/{link_id} required scopes %s/summits/write-presentation-materials %s/summits/write-presentation-links Change-Id: I56a23f0a04cdc254ecaa370afa197a9eebe76a3c
This commit is contained in:
parent
320a9b8f12
commit
5354a39a81
@ -13,7 +13,6 @@
|
||||
**/
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use models\summit\factories\IPresentationVideoFactory;
|
||||
/**
|
||||
* Class FactoriesProvider
|
||||
* @package factories
|
||||
@ -28,6 +27,6 @@ final class FactoriesProvider extends ServiceProvider
|
||||
|
||||
public function register()
|
||||
{
|
||||
App::singleton(IPresentationVideoFactory::class, PresentationVideoFactory::class);
|
||||
|
||||
}
|
||||
}
|
@ -112,18 +112,39 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @param $video_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationVideo($summit_id, $presentation_id, $video_id){
|
||||
try {
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation)) return $this->error404();
|
||||
|
||||
$video = $presentation-getVideoBy($video_id);
|
||||
|
||||
if (is_null($video)) return $this->error404();
|
||||
|
||||
return $this->ok(SerializerRegistry::getInstance()->getSerializer($video)->serialize());
|
||||
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function addVideo(LaravelRequest $request, $summit_id, $presentation_id){
|
||||
try {
|
||||
|
||||
@ -139,6 +160,7 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
'you_tube_id' => 'required|alpha_dash',
|
||||
'name' => 'sometimes|required|text:512',
|
||||
'description' => 'sometimes|required|text|max:512',
|
||||
'featured' => 'sometimes|required|boolean',
|
||||
'display_on_site' => 'sometimes|required|boolean',
|
||||
);
|
||||
|
||||
@ -173,6 +195,13 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @param $video_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function updateVideo(LaravelRequest $request, $summit_id, $presentation_id, $video_id){
|
||||
try {
|
||||
|
||||
@ -189,6 +218,8 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
'name' => 'sometimes|required|text:512',
|
||||
'description' => 'sometimes|required|text|max:512',
|
||||
'display_on_site' => 'sometimes|required|boolean',
|
||||
'featured' => 'sometimes|required|boolean',
|
||||
'order' => 'sometimes|integer|min:1',
|
||||
);
|
||||
|
||||
$data = $data->all();
|
||||
@ -222,6 +253,12 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @param $video_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function deleteVideo($summit_id, $presentation_id, $video_id){
|
||||
try {
|
||||
|
||||
@ -488,4 +525,422 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Slides
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationSlides($summit_id, $presentation_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation)) return $this->error404();
|
||||
|
||||
$slides = $presentation-getSlides();
|
||||
|
||||
$items = [];
|
||||
foreach($slides as $i)
|
||||
{
|
||||
if($i instanceof IEntity)
|
||||
{
|
||||
$i = SerializerRegistry::getInstance()->getSerializer($i)->serialize();
|
||||
}
|
||||
$items[] = $i;
|
||||
}
|
||||
|
||||
return $this->ok($items);
|
||||
|
||||
} catch (ValidationException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error412(array($ex1->getMessage()));
|
||||
} catch (EntityNotFoundException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error404(array('message' => $ex2->getMessage()));
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @param $slide_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationSlide($summit_id, $presentation_id, $slide_id){
|
||||
try {
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation)) return $this->error404();
|
||||
|
||||
$slide = $presentation-getSlideBy($slide_id);
|
||||
|
||||
if (is_null($slide)) return $this->error404();
|
||||
|
||||
return $this->ok(SerializerRegistry::getInstance()->getSerializer($slide)->serialize());
|
||||
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function addPresentationSlide(LaravelRequest $request, $summit_id, $presentation_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$data = $request->all();
|
||||
$rules = [
|
||||
'file' => 'required_without:link',
|
||||
'link' => 'required_without:file|text:512',
|
||||
'name' => 'required|text:512',
|
||||
'description' => 'sometimes|required|text|max:512',
|
||||
'display_on_site' => 'sometimes|required|boolean',
|
||||
'featured' => 'sometimes|required|boolean',
|
||||
];
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data, $rules);
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
$ex->setMessages($validation->messages()->toArray());
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$slide = $this->presentation_service->addSlideTo($request, $presentation_id, $data);
|
||||
|
||||
return $this->created($slide->getId());
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @param $slide_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function updatePresentationSlide(LaravelRequest $request, $summit_id, $presentation_id, $slide_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
$rules = [
|
||||
'link' => 'sometimes|required|text:512',
|
||||
'name' => 'sometimes|required|text:512',
|
||||
'description' => 'sometimes|required|text|max:512',
|
||||
'display_on_site' => 'sometimes|required|boolean',
|
||||
'featured' => 'sometimes|required|boolean',
|
||||
'order' => 'sometimes|integer|min:1',
|
||||
];
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data, $rules);
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
$ex->setMessages($validation->messages()->toArray());
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$this->presentation_service->updateSlide($request, $presentation_id, $slide_id, $data);
|
||||
|
||||
return $this->updated();
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @param $slide_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function deletePresentationSlide($summit_id, $presentation_id, $slide_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$this->presentation_service->deleteSlide($presentation_id, $slide_id);
|
||||
|
||||
return $this->deleted();
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Links
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationLinks($summit_id, $presentation_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation)) return $this->error404();
|
||||
|
||||
$links = $presentation-getLinks();
|
||||
|
||||
$items = [];
|
||||
foreach($links as $i)
|
||||
{
|
||||
if($i instanceof IEntity)
|
||||
{
|
||||
$i = SerializerRegistry::getInstance()->getSerializer($i)->serialize();
|
||||
}
|
||||
$items[] = $i;
|
||||
}
|
||||
|
||||
return $this->ok($items);
|
||||
|
||||
} catch (ValidationException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error412(array($ex1->getMessage()));
|
||||
} catch (EntityNotFoundException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error404(array('message' => $ex2->getMessage()));
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @param $link_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function getPresentationLink($summit_id, $presentation_id, $link_id){
|
||||
try {
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation)) return $this->error404();
|
||||
|
||||
$link = $presentation-getLinkBy($link_id);
|
||||
|
||||
if (is_null($link)) return $this->error404();
|
||||
|
||||
return $this->ok(SerializerRegistry::getInstance()->getSerializer($link)->serialize());
|
||||
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function addPresentationLink(LaravelRequest $request, $summit_id, $presentation_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$data = $request->all();
|
||||
$rules = [
|
||||
'link' => 'required|text:512',
|
||||
'name' => 'required|text:512',
|
||||
'description' => 'sometimes|required|text|max:512',
|
||||
'display_on_site' => 'sometimes|required|boolean',
|
||||
'featured' => 'sometimes|required|boolean',
|
||||
];
|
||||
|
||||
$data = $data->all();
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data, $rules);
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
$ex->setMessages($validation->messages()->toArray());
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$link = $this->presentation_service->addLinkTo($request, $presentation_id, $data);
|
||||
|
||||
return $this->created($link->getId());
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @param $link_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function updatePresentationLink(LaravelRequest $request, $summit_id, $presentation_id, $link_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
$rules = [
|
||||
'link' => 'sometimes|required|text:512',
|
||||
'name' => 'sometimes|required|text:512',
|
||||
'description' => 'sometimes|required|text|max:512',
|
||||
'display_on_site' => 'sometimes|required|boolean',
|
||||
'featured' => 'sometimes|required|boolean',
|
||||
'order' => 'sometimes|integer|min:1',
|
||||
];
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data, $rules);
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException;
|
||||
$ex->setMessages($validation->messages()->toArray());
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$this->presentation_service->updateLink($request, $presentation_id, $link_id, $data);
|
||||
|
||||
return $this->updated();
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $presentation_id
|
||||
* @param $link_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function deletePresentationLink($summit_id, $presentation_id, $link_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$this->presentation_service->deleteLink($presentation_id, $link_id);
|
||||
|
||||
return $this->deleted();
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
{
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
/**
|
||||
* Copyright 2016 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -37,7 +36,6 @@ use utils\OrderParser;
|
||||
use utils\PagingInfo;
|
||||
use Illuminate\Http\Request as LaravelRequest;
|
||||
use utils\PagingResponse;
|
||||
|
||||
/**
|
||||
* Class OAuth2SummitSpeakersApiController
|
||||
* @package App\Http\Controllers
|
||||
|
@ -20,7 +20,7 @@ use models\main\File;
|
||||
* Class FileUploader
|
||||
* @package App\Http\Utils
|
||||
*/
|
||||
final class FileUploader
|
||||
final class FileUploader implements IFileUploader
|
||||
{
|
||||
/**
|
||||
* @var IFolderService
|
||||
@ -35,6 +35,7 @@ final class FileUploader
|
||||
/**
|
||||
* FileUploader constructor.
|
||||
* @param IFolderService $folder_service
|
||||
* @param IBucket $bucket
|
||||
*/
|
||||
public function __construct(IFolderService $folder_service, IBucket $bucket){
|
||||
$this->folder_service = $folder_service;
|
||||
@ -43,9 +44,10 @@ final class FileUploader
|
||||
|
||||
/**
|
||||
* @param UploadedFile $file
|
||||
* @param string $folder_name
|
||||
* @param $folder_name
|
||||
* @param bool $is_image
|
||||
* @return File
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function build(UploadedFile $file, $folder_name, $is_image = false){
|
||||
$attachment = new File();
|
||||
@ -59,7 +61,9 @@ final class FileUploader
|
||||
$attachment->setFilename(sprintf("assets/%s/%s", $folder_name, $file->getClientOriginalName()));
|
||||
$attachment->setTitle(str_replace(array('-', '_'), ' ', preg_replace('/\.[^.]+$/', '', $file->getClientOriginalName())));
|
||||
$attachment->setShowInSearch(true);
|
||||
if ($is_image) $attachment->setImage();
|
||||
if ($is_image) // set className
|
||||
$attachment->setImage();
|
||||
|
||||
$this->bucket->put($attachment, $local_path);
|
||||
$attachment->setCloudMeta('LastPut', time());
|
||||
$attachment->setCloudStatus('Live');
|
||||
@ -68,7 +72,7 @@ final class FileUploader
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
Log::error($ex);
|
||||
$attachment->setCloudStatus('Error');
|
||||
throw $ex;
|
||||
}
|
||||
return $attachment;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php namespace models\summit\factories;
|
||||
<?php namespace App\Http\Utils;
|
||||
/**
|
||||
* Copyright 2016 OpenStack Foundation
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -11,17 +11,20 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use models\summit\PresentationVideo;
|
||||
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use models\main\File;
|
||||
/**
|
||||
* Interface IPresentationVideoFactory
|
||||
* @package models\summit\factories
|
||||
* Interface IFileUploader
|
||||
* @package App\Http\Utils
|
||||
*/
|
||||
interface IPresentationVideoFactory
|
||||
interface IFileUploader
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
* @return PresentationVideo
|
||||
* @param UploadedFile $file
|
||||
* @param $folder_name
|
||||
* @param bool $is_image
|
||||
* @return File
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function build(array $data);
|
||||
public function build(UploadedFile $file, $folder_name, $is_image = false);
|
||||
}
|
34
app/Http/Utils/UtilsProvider.php
Normal file
34
app/Http/Utils/UtilsProvider.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php namespace App\Http\Utils;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\App;
|
||||
/**
|
||||
* Class UtilsProvider
|
||||
* @package App\Http\Utils
|
||||
*/
|
||||
final class UtilsProvider extends ServiceProvider
|
||||
{
|
||||
protected $defer = false;
|
||||
|
||||
public function boot()
|
||||
{
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
// file uploadedr service
|
||||
App::singleton(IBucket::class, SwiftBucket::class);
|
||||
App::singleton(IFileUploader ::class, FileUploader::class);
|
||||
}
|
||||
}
|
@ -93,6 +93,7 @@ Route::group([
|
||||
});
|
||||
});
|
||||
Route::post('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitApiController@addSummit']);
|
||||
|
||||
Route::group(['prefix' => '{id}'], function () {
|
||||
Route::put('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitApiController@updateSummit']);
|
||||
Route::delete('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitApiController@deleteSummit']);
|
||||
@ -268,16 +269,38 @@ Route::group([
|
||||
|
||||
Route::delete('', 'OAuth2PresentationApiController@deletePresentation');
|
||||
|
||||
// videos
|
||||
Route::group(['prefix' => 'videos'], function () {
|
||||
|
||||
Route::get('', 'OAuth2PresentationApiController@getPresentationVideos');
|
||||
Route::get('{video_id}', 'OAuth2PresentationApiController@getPresentationVideo');
|
||||
Route::post('', [ 'middleware' => 'auth.user:administrators|video-admins', 'uses' => 'OAuth2PresentationApiController@addVideo' ]);
|
||||
Route::group(['prefix' => '{video_id}'], function () {
|
||||
Route::get('', 'OAuth2PresentationApiController@getPresentationVideo');
|
||||
Route::put('', [ 'middleware' => 'auth.user:administrators|video-admins', 'uses' => 'OAuth2PresentationApiController@updateVideo' ]);
|
||||
Route::delete('', [ 'middleware' => 'auth.user:administrators|video-admins', 'uses' => 'OAuth2PresentationApiController@deleteVideo' ]);
|
||||
});
|
||||
});
|
||||
|
||||
// slides
|
||||
Route::group(['prefix' => 'slides'], function () {
|
||||
Route::get('', 'OAuth2PresentationApiController@getPresentationSlides');
|
||||
Route::post('', [ 'middleware' => 'auth.user:administrators', 'uses' => 'OAuth2PresentationApiController@addPresentationSlide' ]);
|
||||
Route::group(['prefix' => '{slide_id}'], function () {
|
||||
Route::get('', 'OAuth2PresentationApiController@getPresentationSlide');
|
||||
Route::put('', [ 'middleware' => 'auth.user:administrators', 'uses' => 'OAuth2PresentationApiController@updatePresentationSlide' ]);
|
||||
Route::delete('', [ 'middleware' => 'auth.user:administrators', 'uses' => 'OAuth2PresentationApiController@deletePresentationSlide' ]);
|
||||
});
|
||||
});
|
||||
|
||||
// links
|
||||
Route::group(['prefix' => 'links'], function () {
|
||||
Route::get('', 'OAuth2PresentationApiController@getPresentationLinks');
|
||||
Route::post('', [ 'middleware' => 'auth.user:administrators', 'uses' => 'OAuth2PresentationApiController@addPresentationLink' ]);
|
||||
Route::group(['prefix' => '{link_id}'], function () {
|
||||
Route::get('', 'OAuth2PresentationApiController@getPresentationLink');
|
||||
Route::put('', [ 'middleware' => 'auth.user:administrators', 'uses' => 'OAuth2PresentationApiController@updatePresentationLink' ]);
|
||||
Route::delete('', [ 'middleware' => 'auth.user:administrators', 'uses' => 'OAuth2PresentationApiController@deletePresentationLink' ]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -199,6 +199,9 @@ class File extends SilverstripeBaseModel
|
||||
parent::__construct();
|
||||
$this->class_name = 'CloudFile';
|
||||
$this->show_in_search = true;
|
||||
$this->cloud_metajson = "";
|
||||
$this->cloud_status = "Local";
|
||||
$this->cloud_size = 0;
|
||||
}
|
||||
|
||||
public function setImage(){
|
||||
|
@ -11,12 +11,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Events\PresentationMaterialCreated;
|
||||
use App\Models\Foundation\Main\IOrderable;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="PresentationMaterial")
|
||||
@ -27,7 +26,7 @@ use Illuminate\Support\Facades\Event;
|
||||
* Class PresentationMaterial
|
||||
* @package models\summit
|
||||
*/
|
||||
abstract class PresentationMaterial extends SilverstripeBaseModel
|
||||
abstract class PresentationMaterial extends SilverstripeBaseModel implements IOrderable
|
||||
{
|
||||
|
||||
/**
|
||||
@ -197,7 +196,7 @@ abstract class PresentationMaterial extends SilverstripeBaseModel
|
||||
* @ORM\PostPersist
|
||||
*/
|
||||
public function inserted($args){
|
||||
Event::fire(new PresentationMaterialCreated($this, $args));
|
||||
Event::fire(new PresentationMaterialCreated($this));
|
||||
}
|
||||
|
||||
public function clearPresentation(){
|
||||
|
@ -11,10 +11,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use models\main\File;
|
||||
use models\main\Image;
|
||||
use Config;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
/**
|
||||
* @ORM\Entity
|
||||
@ -39,7 +36,7 @@ class PresentationSlide extends PresentationMaterial
|
||||
private $link;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\File")
|
||||
* @ORM\ManyToOne(targetEntity="models\main\File", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="SlideID", referencedColumnName="ID")
|
||||
* @var File
|
||||
*/
|
||||
@ -89,7 +86,7 @@ class PresentationSlide extends PresentationMaterial
|
||||
*/
|
||||
public function getSlideId(){
|
||||
try{
|
||||
return !is_null($this->slide)?$this->slide->getId():0;
|
||||
return !is_null($this->slide) ? $this->slide->getId():0;
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
return 0;
|
||||
|
@ -11,6 +11,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Models\Foundation\Main\OrderableChilds;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use App\Models\Foundation\Summit\Events\Presentations\TrackQuestions\TrackAnswer;
|
||||
use App\Models\Foundation\Summit\SelectionPlan;
|
||||
@ -315,6 +317,8 @@ class Presentation extends SummitEvent
|
||||
public function addVideo(PresentationVideo $video){
|
||||
$this->materials->add($video);
|
||||
$video->setPresentation($this);
|
||||
$video->setOrder($this->getMaterialsMaxOrder() + 1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -335,6 +339,28 @@ class Presentation extends SummitEvent
|
||||
return $res === false ? null : $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $slide_id
|
||||
* @return PresentationSlide
|
||||
*/
|
||||
public function getSlideBy($slide_id){
|
||||
$res = $this->materials
|
||||
->filter(function( $element) use($slide_id) { return $element instanceof PresentationSlide && $element->getId() == $slide_id; })
|
||||
->first();
|
||||
return $res === false ? null : $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $link_id
|
||||
* @return PresentationLink
|
||||
*/
|
||||
public function getLinkBy($link_id){
|
||||
$res = $this->materials
|
||||
->filter(function( $element) use($link_id) { return $element instanceof PresentationLink && $element->getId() == $link_id; })
|
||||
->first();
|
||||
return $res === false ? null : $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationVideo $video
|
||||
*/
|
||||
@ -343,6 +369,22 @@ class Presentation extends SummitEvent
|
||||
$video->unsetPresentation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationSlide $slide
|
||||
*/
|
||||
public function removeSlide(PresentationSlide $slide){
|
||||
$this->materials->removeElement($slide);
|
||||
$slide->unsetPresentation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationLink $link
|
||||
*/
|
||||
public function removeLink(PresentationLink $link){
|
||||
$this->materials->removeElement($link);
|
||||
$link->unsetPresentation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationSpeaker $speaker
|
||||
*/
|
||||
@ -374,6 +416,18 @@ class Presentation extends SummitEvent
|
||||
public function addSlide(PresentationSlide $slide){
|
||||
$this->materials->add($slide);
|
||||
$slide->setPresentation($this);
|
||||
$slide->setOrder($this->getMaterialsMaxOrder() + 1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
private function getMaterialsMaxOrder(){
|
||||
$criteria = Criteria::create();
|
||||
$criteria->orderBy(['order' => 'DESC']);
|
||||
$material = $this->materials->matching($criteria)->first();
|
||||
return $material === false ? 0 : $material->getOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -404,6 +458,8 @@ class Presentation extends SummitEvent
|
||||
public function addLink(PresentationLink $link){
|
||||
$this->materials->add($link);
|
||||
$link->setPresentation($this);
|
||||
$link->setOrder($this->getMaterialsMaxOrder() + 1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -750,4 +806,15 @@ class Presentation extends SummitEvent
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationMaterial $material
|
||||
* @param int $new_order
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function recalculateMaterialOrder(PresentationMaterial $material, $new_order){
|
||||
self::recalculateOrderForSelectable($this->materials, $material, $new_order);
|
||||
}
|
||||
|
||||
use OrderableChilds;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
<?php namespace App\Models\Foundation\Summit\Factories;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use models\summit\PresentationLink;
|
||||
/**
|
||||
* Class PresentationLinkFactory
|
||||
* @package App\Models\Foundation\Summit\Factories
|
||||
*/
|
||||
final class PresentationLinkFactory
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
* @return PresentationLink
|
||||
*/
|
||||
public static function build(array $data){
|
||||
return self::populate(new PresentationLink, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationLink $slide
|
||||
* @param array $data
|
||||
* @return PresentationLink
|
||||
*/
|
||||
public static function populate(PresentationLink $link, array $data){
|
||||
|
||||
PresentationMaterialFactory::populate($link, $data);
|
||||
if(isset($data['link']))
|
||||
$link->setLink(trim($data['link']));
|
||||
|
||||
return $link;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?php namespace App\Models\Foundation\Summit\Factories;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use models\summit\PresentationMaterial;
|
||||
/**
|
||||
* Class PresentationMaterialFactory
|
||||
* @package App\Models\Foundation\Summit\Factories
|
||||
*/
|
||||
abstract class PresentationMaterialFactory
|
||||
{
|
||||
/**
|
||||
* @param PresentationMaterial $presentationMaterial
|
||||
* @param array $data
|
||||
* @return PresentationMaterial
|
||||
*/
|
||||
public static function populate(PresentationMaterial $presentationMaterial, array $data){
|
||||
|
||||
if(isset($data['name']))
|
||||
$presentationMaterial->setName(trim($data['name']));
|
||||
|
||||
if(isset($data['description']))
|
||||
$presentationMaterial->setDescription(trim($data['description']));
|
||||
|
||||
if(isset($data['display_on_site']))
|
||||
$presentationMaterial->setDisplayOnSite(isset($data['display_on_site']) ? (bool)$data['display_on_site'] : true);
|
||||
|
||||
return $presentationMaterial;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php namespace App\Models\Foundation\Summit\Factories;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use models\summit\PresentationSlide;
|
||||
/**
|
||||
* Class PresentationSlideFactory
|
||||
* @package App\Models\Foundation\Summit\Factories
|
||||
*/
|
||||
final class PresentationSlideFactory
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
* @return PresentationSlide
|
||||
*/
|
||||
public static function build(array $data){
|
||||
return self::populate(new PresentationSlide, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationSlide $slide
|
||||
* @param array $data
|
||||
* @return PresentationSlide
|
||||
*/
|
||||
public static function populate(PresentationSlide $slide, array $data){
|
||||
|
||||
PresentationMaterialFactory::populate($slide, $data);
|
||||
if(isset($data['link']))
|
||||
$slide->setLink(trim($data['link']));
|
||||
|
||||
return $slide;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php namespace factories;
|
||||
<?php namespace App\Models\Foundation\Summit\Factories;
|
||||
/**
|
||||
* Copyright 2016 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -11,35 +11,33 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use models\summit\factories\IPresentationVideoFactory;
|
||||
use models\summit\PresentationVideo;
|
||||
|
||||
/**
|
||||
* Class PresentationVideoFactory
|
||||
* @package factories
|
||||
*/
|
||||
final class PresentationVideoFactory implements IPresentationVideoFactory
|
||||
final class PresentationVideoFactory
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
* @return PresentationVideo
|
||||
*/
|
||||
public function build(array $data){
|
||||
$video = new PresentationVideo;
|
||||
$utc_now = new \DateTime();
|
||||
public static function build(array $data){
|
||||
return self::populate(new PresentationVideo, $data);
|
||||
}
|
||||
|
||||
$video->setYoutubeId(trim($data['you_tube_id']));
|
||||
$video->setDateUploaded($utc_now);
|
||||
|
||||
if(isset($data['name']))
|
||||
$video->setName(trim($data['name']));
|
||||
|
||||
if(isset($data['description']))
|
||||
$video->setDescription(trim($data['description']));
|
||||
|
||||
$video->setDisplayOnSite(isset($data['display_on_site']) ? (bool)$data['display_on_site'] : true);
|
||||
/**
|
||||
* @param PresentationVideo $video
|
||||
* @param array $data
|
||||
* @return PresentationVideo
|
||||
*/
|
||||
public static function populate(PresentationVideo $video, array $data){
|
||||
|
||||
PresentationMaterialFactory::populate($video, $data);
|
||||
if(isset($data['you_tube_id']))
|
||||
$video->setYoutubeId(trim($data['you_tube_id']));
|
||||
if($video->getId() == 0)
|
||||
$video->setDateUploaded(new \DateTime());
|
||||
return $video;
|
||||
}
|
||||
}
|
@ -851,6 +851,12 @@ class Summit extends SilverstripeBaseModel
|
||||
}
|
||||
|
||||
|
||||
public function getPublishedPresentations()
|
||||
{
|
||||
$query = $this->createQuery("SELECT p from models\summit\Presentation p JOIN p.summit s WHERE s.id = :summit_id and p.published = 1");
|
||||
return $query->setParameter('summit_id', $this->getIdentifier())->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationSpeaker $speaker
|
||||
* @param SelectionPlan|null $selectionPlan
|
||||
|
@ -31,9 +31,14 @@ final class SummitScopes
|
||||
const WriteMySpeakersData = '%s/speakers/write/me';
|
||||
const ReadMySpeakersData = '%s/speakers/read/me';
|
||||
|
||||
const PublishEventData = '%s/summits/publish-event';
|
||||
const WriteEventData = '%s/summits/write-event';
|
||||
const WriteVideoData = '%s/summits/write-videos';
|
||||
const PublishEventData = '%s/summits/publish-event';
|
||||
const WriteEventData = '%s/summits/write-event';
|
||||
const WriteVideoData = '%s/summits/write-videos';
|
||||
const WritePresentationVideosData = '%s/summits/write-presentation-videos';
|
||||
const WritePresentationLinksData = '%s/summits/write-presentation-links';
|
||||
const WritePresentationSlidesData = '%s/summits/write-presentation-slides';
|
||||
const WritePresentationMaterialsData = '%s/summits/write-presentation-materials';
|
||||
|
||||
|
||||
const WriteAttendeesData = '%s/attendees/write';
|
||||
|
||||
|
@ -16,8 +16,11 @@ use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\main\Member;
|
||||
use models\summit\Presentation;
|
||||
use models\summit\PresentationLink;
|
||||
use models\summit\PresentationSlide;
|
||||
use models\summit\PresentationVideo;
|
||||
use models\summit\Summit;
|
||||
use Illuminate\Http\Request as LaravelRequest;
|
||||
/**
|
||||
* Interface IPresentationService
|
||||
* @package services\model
|
||||
@ -88,4 +91,71 @@ interface IPresentationService
|
||||
* @return void
|
||||
*/
|
||||
public function deletePresentation(Summit $summit, Member $member, $presentation_id);
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
* @param int $presentation_id
|
||||
* @param array $slide_data
|
||||
* @param array $allowed_extensions
|
||||
* @param int $max_file_size
|
||||
* @return mixed|PresentationSlide
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addSlideTo
|
||||
(
|
||||
LaravelRequest $request,
|
||||
$presentation_id,
|
||||
array $slide_data,
|
||||
array $allowed_extensions = ['ppt', 'pptx', 'xps', 'key', 'pdf'],
|
||||
$max_file_size = 10485760
|
||||
);
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
* @param int $presentation_id
|
||||
* @param int $slide_id
|
||||
* @param array $slide_data
|
||||
* @param array $allowed_extensions
|
||||
* @param int $max_file_size
|
||||
* @return mixed|PresentationSlide
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function updateSlide
|
||||
(
|
||||
LaravelRequest $request,
|
||||
$presentation_id,
|
||||
$slide_id,
|
||||
array $slide_data,
|
||||
array $allowed_extensions = ['ppt', 'pptx', 'xps', 'key', 'pdf'],
|
||||
$max_file_size = 10485760
|
||||
);
|
||||
|
||||
/**
|
||||
* @param int $presentation_id
|
||||
* @param int $slide_id
|
||||
* @return void
|
||||
*/
|
||||
public function deleteSlide($presentation_id, $slide_id);
|
||||
|
||||
/**
|
||||
* @param $presentation_id
|
||||
* @param array $link_data
|
||||
* @return PresentationLink
|
||||
*/
|
||||
public function addLinkTo($presentation_id, array $link_data);
|
||||
|
||||
/**
|
||||
* @param $presentation_id
|
||||
* @param $link_id
|
||||
* @param array $link_data
|
||||
* @return PresentationLink
|
||||
*/
|
||||
public function updateLink($presentation_id, $link_id, array $link_data);
|
||||
|
||||
/**
|
||||
* @param int $presentation_id
|
||||
* @param int $link_id
|
||||
* @return void
|
||||
*/
|
||||
public function deleteLink($presentation_id, $link_id);
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
<?php namespace services\model;
|
||||
|
||||
/**
|
||||
* Copyright 2016 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -14,6 +13,10 @@
|
||||
**/
|
||||
use App\Events\PresentationMaterialDeleted;
|
||||
use App\Events\PresentationMaterialUpdated;
|
||||
use App\Http\Utils\IFileUploader;
|
||||
use App\Models\Foundation\Summit\Factories\PresentationLinkFactory;
|
||||
use App\Models\Foundation\Summit\Factories\PresentationSlideFactory;
|
||||
use App\Models\Foundation\Summit\Factories\PresentationVideoFactory;
|
||||
use App\Models\Foundation\Summit\SelectionPlan;
|
||||
use App\Services\Model\AbstractService;
|
||||
use App\Models\Foundation\Summit\Events\Presentations\TrackQuestions\TrackAnswer;
|
||||
@ -22,17 +25,18 @@ use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\main\ITagRepository;
|
||||
use models\main\Member;
|
||||
use models\summit\factories\IPresentationVideoFactory;
|
||||
use models\summit\ISpeakerRepository;
|
||||
use models\summit\ISummitEventRepository;
|
||||
use models\summit\Presentation;
|
||||
use models\summit\PresentationLink;
|
||||
use models\summit\PresentationSlide;
|
||||
use models\summit\PresentationSpeaker;
|
||||
use models\summit\PresentationType;
|
||||
use models\summit\PresentationVideo;
|
||||
use libs\utils\ITransactionService;
|
||||
use models\summit\Summit;
|
||||
|
||||
use Illuminate\Http\Request as LaravelRequest;
|
||||
use App\Services\Model\IFolderService;
|
||||
/**
|
||||
* Class PresentationService
|
||||
* @package services\model
|
||||
@ -46,11 +50,6 @@ final class PresentationService
|
||||
*/
|
||||
private $presentation_repository;
|
||||
|
||||
/**
|
||||
* @var IPresentationVideoFactory
|
||||
*/
|
||||
private $video_factory;
|
||||
|
||||
/**
|
||||
* @var ISpeakerRepository
|
||||
*/
|
||||
@ -61,21 +60,32 @@ final class PresentationService
|
||||
*/
|
||||
private $tag_repository;
|
||||
|
||||
/**
|
||||
* @var IFolderService
|
||||
*/
|
||||
private $folder_service;
|
||||
|
||||
/**
|
||||
* @var IFileUploader
|
||||
*/
|
||||
private $file_uploader;
|
||||
|
||||
/**
|
||||
* PresentationService constructor.
|
||||
* @param IPresentationVideoFactory $video_factory
|
||||
* @param ISummitEventRepository $presentation_repository
|
||||
* @param ISpeakerRepository $speaker_repository
|
||||
* @param ITagRepository $tag_repository
|
||||
* @param IFolderService $folder_service
|
||||
* @param IFileUploader $file_uploader
|
||||
* @param ITransactionService $tx_service
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
IPresentationVideoFactory $video_factory,
|
||||
ISummitEventRepository $presentation_repository,
|
||||
ISpeakerRepository $speaker_repository,
|
||||
ITagRepository $tag_repository,
|
||||
IFolderService $folder_service,
|
||||
IFileUploader $file_uploader,
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
@ -83,7 +93,8 @@ final class PresentationService
|
||||
$this->presentation_repository = $presentation_repository;
|
||||
$this->speaker_repository = $speaker_repository;
|
||||
$this->tag_repository = $tag_repository;
|
||||
$this->video_factory = $video_factory;
|
||||
$this->folder_service = $folder_service;
|
||||
$this->file_uploader = $file_uploader;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,7 +120,7 @@ final class PresentationService
|
||||
|
||||
if (!isset($video_data['name'])) $video_data['name'] = $presentation->getTitle();
|
||||
|
||||
$video = $this->video_factory->build($video_data);
|
||||
$video = PresentationVideoFactory::build($video_data);
|
||||
|
||||
$presentation->addVideo($video);
|
||||
|
||||
@ -145,17 +156,12 @@ final class PresentationService
|
||||
if (!$video instanceof PresentationVideo)
|
||||
throw new EntityNotFoundException('video not found!');
|
||||
|
||||
if (isset($video_data['name']))
|
||||
$video->setName(trim($video_data['name']));
|
||||
PresentationVideoFactory::populate($video, $video_data);
|
||||
|
||||
if (isset($video_data['you_tube_id']))
|
||||
$video->setYoutubeId(trim($video_data['you_tube_id']));
|
||||
|
||||
if (isset($video_data['description']))
|
||||
$video->setDescription(trim($video_data['description']));
|
||||
|
||||
if (isset($video_data['display_on_site']))
|
||||
$video->setDisplayOnSite((bool)$video_data['display_on_site']);
|
||||
if (isset($data['order']) && intval($video_data['order']) != $video->getOrder()) {
|
||||
// request to update order
|
||||
$presentation->recalculateMaterialOrder($video, intval($video_data['order']));
|
||||
}
|
||||
|
||||
return $video;
|
||||
|
||||
@ -266,7 +272,6 @@ final class PresentationService
|
||||
$data
|
||||
);
|
||||
|
||||
|
||||
return $presentation;
|
||||
});
|
||||
|
||||
@ -593,4 +598,276 @@ final class PresentationService
|
||||
return $presentation;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
* @param int $presentation_id
|
||||
* @param array $slide_data
|
||||
* @param array $allowed_extensions
|
||||
* @param int $max_file_size
|
||||
* @return mixed|PresentationSlide
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addSlideTo
|
||||
(
|
||||
LaravelRequest $request,
|
||||
$presentation_id,
|
||||
array $slide_data,
|
||||
array $allowed_extensions = ['ppt', 'pptx', 'xps', 'key', 'pdf'],
|
||||
$max_file_size = 10485760
|
||||
)
|
||||
{
|
||||
$slide = $this->tx_service->transaction(function () use (
|
||||
$request,
|
||||
$presentation_id,
|
||||
$slide_data,
|
||||
$max_file_size,
|
||||
$allowed_extensions
|
||||
) {
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation))
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
if (!$presentation instanceof Presentation)
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
$slide = PresentationSlideFactory::build($slide_data);
|
||||
|
||||
// check if there is any file sent
|
||||
if($request->hasFile('file')){
|
||||
$file = $request->file('file');
|
||||
if (!in_array($file->extension(), $allowed_extensions)) {
|
||||
throw new ValidationException(
|
||||
sprintf("file does not has a valid extension '(%s)'.", implode("','", $allowed_extensions)));
|
||||
}
|
||||
|
||||
if ($file->getSize() > $max_file_size) {
|
||||
throw new ValidationException(sprintf("file exceeds max_file_size (%s MB).", ($max_file_size / 1024) / 1024));
|
||||
}
|
||||
|
||||
$slideFile = $this->file_uploader->build(
|
||||
$file,
|
||||
sprintf('summits/%s/presentations/%s/slides/', $presentation->getSummitId(), $presentation_id),
|
||||
false);
|
||||
$slide->setSlide($slideFile);
|
||||
}
|
||||
|
||||
$presentation->addSlide($slide);
|
||||
|
||||
return $slide;
|
||||
});
|
||||
|
||||
return $slide;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
* @param int $presentation_id
|
||||
* @param int $slide_id
|
||||
* @param array $slide_data
|
||||
* @param array $allowed_extensions
|
||||
* @param int $max_file_size
|
||||
* @return mixed|PresentationSlide
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function updateSlide
|
||||
(
|
||||
LaravelRequest $request,
|
||||
$presentation_id,
|
||||
$slide_id,
|
||||
array $slide_data,
|
||||
array $allowed_extensions = ['ppt', 'pptx', 'xps', 'key', 'pdf'],
|
||||
$max_file_size = 10485760
|
||||
){
|
||||
$slide = $this->tx_service->transaction(function () use
|
||||
(
|
||||
$request,
|
||||
$presentation_id,
|
||||
$slide_data,
|
||||
$max_file_size,
|
||||
$allowed_extensions,
|
||||
$slide_id
|
||||
) {
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation))
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
if (!$presentation instanceof Presentation)
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
$slide = $presentation->getSlideBy($slide_id);
|
||||
|
||||
if (is_null($slide))
|
||||
throw new EntityNotFoundException('slide not found!');
|
||||
|
||||
if (!$slide instanceof PresentationSlide)
|
||||
throw new EntityNotFoundException('slide not found!');
|
||||
|
||||
PresentationSlideFactory::populate($slide, $slide_data);
|
||||
|
||||
// check if there is any file sent
|
||||
if($request->hasFile('file')){
|
||||
$file = $request->file('file');
|
||||
if (!in_array($file->extension(), $allowed_extensions)) {
|
||||
throw new ValidationException(
|
||||
sprintf("file does not has a valid extension '(%s)'.", implode("','", $allowed_extensions)));
|
||||
}
|
||||
|
||||
if ($file->getSize() > $max_file_size) {
|
||||
throw new ValidationException(sprintf("file exceeds max_file_size (%s MB).", ($max_file_size / 1024) / 1024));
|
||||
}
|
||||
|
||||
$slideFile = $this->file_uploader->build($file, sprintf('summits/%s/presentations/%s/slides/', $presentation->getSummitId(), $presentation_id), false);
|
||||
$slide->setSlide($slideFile);
|
||||
}
|
||||
|
||||
if (isset($data['order']) && intval($slide_data['order']) != $slide->getOrder()) {
|
||||
// request to update order
|
||||
$presentation->recalculateMaterialOrder($slide, intval($slide_data['order']));
|
||||
}
|
||||
|
||||
return $slide;
|
||||
|
||||
});
|
||||
|
||||
Event::fire(new PresentationMaterialUpdated($slide));
|
||||
return $slide;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $presentation_id
|
||||
* @param int $slide_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
*/
|
||||
public function deleteSlide($presentation_id, $slide_id)
|
||||
{
|
||||
$this->tx_service->transaction(function () use ($presentation_id, $slide_id) {
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation))
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
if (!$presentation instanceof Presentation)
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
$slide = $presentation->getSlideBy($slide_id);
|
||||
|
||||
if (is_null($slide))
|
||||
throw new EntityNotFoundException('slide not found!');
|
||||
|
||||
if (!$slide instanceof PresentationSlide)
|
||||
throw new EntityNotFoundException('slide not found!');
|
||||
|
||||
$presentation->removeSlide($slide);
|
||||
|
||||
Event::fire(new PresentationMaterialDeleted($presentation, $slide_id, 'PresentationSlide'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $presentation_id
|
||||
* @param array $link_data
|
||||
* @return PresentationLink
|
||||
*/
|
||||
public function addLinkTo($presentation_id, array $link_data)
|
||||
{
|
||||
$link = $this->tx_service->transaction(function () use (
|
||||
$presentation_id,
|
||||
$link_data
|
||||
) {
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation))
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
if (!$presentation instanceof Presentation)
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
$link = PresentationLinkFactory::build($link_data);
|
||||
|
||||
$presentation->addLink($link);
|
||||
|
||||
return $link;
|
||||
});
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $presentation_id
|
||||
* @param $link_id
|
||||
* @param array $link_data
|
||||
* @return PresentationLink
|
||||
*/
|
||||
public function updateLink($presentation_id, $link_id, array $link_data)
|
||||
{
|
||||
$link = $this->tx_service->transaction(function () use (
|
||||
$presentation_id,
|
||||
$link_id,
|
||||
$link_data
|
||||
) {
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation))
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
if (!$presentation instanceof Presentation)
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
$link = $presentation->getLinkBy($link_id);
|
||||
|
||||
if (is_null($link))
|
||||
throw new EntityNotFoundException('link not found!');
|
||||
|
||||
if (!$link instanceof PresentationLink)
|
||||
throw new EntityNotFoundException('link not found!');
|
||||
|
||||
$link = PresentationLinkFactory::populate($link, $link_data);
|
||||
|
||||
|
||||
return $link;
|
||||
});
|
||||
|
||||
Event::fire(new PresentationMaterialUpdated($link));
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $presentation_id
|
||||
* @param int $link_id
|
||||
* @return void
|
||||
*/
|
||||
public function deleteLink($presentation_id, $link_id)
|
||||
{
|
||||
$this->tx_service->transaction(function () use ($presentation_id, $link_id) {
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation))
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
if (!$presentation instanceof Presentation)
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
$link = $presentation->getLinkBy($link_id);
|
||||
|
||||
if (is_null($link))
|
||||
throw new EntityNotFoundException('link not found!');
|
||||
|
||||
if (!$link instanceof PresentationSlide)
|
||||
throw new EntityNotFoundException('link not found!');
|
||||
|
||||
$presentation->removeLink($link);
|
||||
|
||||
Event::fire(new PresentationMaterialDeleted($presentation, $link_id, 'PresentationLink'));
|
||||
});
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Http\Utils\SwiftBucket;
|
||||
use App\Models\Foundation\Main\CountryCodes;
|
||||
use App\Models\Foundation\Main\Repositories\ILanguageRepository;
|
||||
use App\Models\Foundation\Summit\Factories\PresentationSpeakerSummitAssistanceConfirmationRequestFactory;
|
||||
@ -45,7 +44,7 @@ use models\summit\SpeakerRegistrationRequest;
|
||||
use models\summit\SpeakerSummitRegistrationPromoCode;
|
||||
use models\summit\SpeakerTravelPreference;
|
||||
use models\summit\Summit;
|
||||
use App\Http\Utils\FileUploader;
|
||||
use App\Http\Utils\IFileUploader;
|
||||
|
||||
/**
|
||||
* Class SpeakerService
|
||||
@ -105,6 +104,11 @@ final class SpeakerService
|
||||
*/
|
||||
private $speaker_involvement_repository;
|
||||
|
||||
/**
|
||||
* @var IFileUploader
|
||||
*/
|
||||
private $file_uploader;
|
||||
|
||||
/**
|
||||
* SpeakerService constructor.
|
||||
* @param ISpeakerRepository $speaker_repository
|
||||
@ -117,6 +121,7 @@ final class SpeakerService
|
||||
* @param ILanguageRepository $language_repository
|
||||
* @param ISpeakerOrganizationalRoleRepository $speaker_organizational_role_repository
|
||||
* @param ISpeakerActiveInvolvementRepository $speaker_involvement_repository
|
||||
* @param IFileUploader $file_uploader
|
||||
* @param ITransactionService $tx_service
|
||||
*/
|
||||
public function __construct
|
||||
@ -131,6 +136,7 @@ final class SpeakerService
|
||||
ILanguageRepository $language_repository,
|
||||
ISpeakerOrganizationalRoleRepository $speaker_organizational_role_repository,
|
||||
ISpeakerActiveInvolvementRepository $speaker_involvement_repository,
|
||||
IFileUploader $file_uploader,
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
@ -145,6 +151,7 @@ final class SpeakerService
|
||||
$this->language_repository = $language_repository;
|
||||
$this->speaker_organizational_role_repository = $speaker_organizational_role_repository;
|
||||
$this->speaker_involvement_repository = $speaker_involvement_repository;
|
||||
$this->file_uploader = $file_uploader;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -571,8 +578,7 @@ final class SpeakerService
|
||||
throw new ValidationException(sprintf("file exceeds max_file_size (%s MB).", ($max_file_size / 1024) / 1024));
|
||||
}
|
||||
|
||||
$uploader = new FileUploader($this->folder_service, new SwiftBucket());
|
||||
$photo = $uploader->build($file, 'profile-images', true);
|
||||
$photo = $this->file_uploader->build($file, 'profile-images', true);
|
||||
$speaker->setPhoto($photo);
|
||||
|
||||
return $photo;
|
||||
|
@ -24,7 +24,7 @@ use App\Events\LocationUpdated;
|
||||
use App\Events\SummitVenueRoomDeleted;
|
||||
use App\Events\SummitVenueRoomInserted;
|
||||
use App\Events\SummitVenueRoomUpdated;
|
||||
use App\Http\Utils\FileUploader;
|
||||
use App\Http\Utils\IFileUploader;
|
||||
use App\Models\Foundation\Summit\Factories\SummitLocationBannerFactory;
|
||||
use App\Models\Foundation\Summit\Factories\SummitLocationFactory;
|
||||
use App\Models\Foundation\Summit\Factories\SummitLocationImageFactory;
|
||||
@ -71,10 +71,11 @@ final class SummitLocationService
|
||||
private $folder_service;
|
||||
|
||||
/**
|
||||
* LocationService constructor.
|
||||
* SummitLocationService constructor.
|
||||
* @param ISummitLocationRepository $location_repository
|
||||
* @param IGeoCodingAPI $geo_coding_api
|
||||
* @param IFolderService $folder_service
|
||||
* @param IFileUploader $file_uploader
|
||||
* @param ITransactionService $tx_service
|
||||
*/
|
||||
public function __construct
|
||||
@ -82,12 +83,14 @@ final class SummitLocationService
|
||||
ISummitLocationRepository $location_repository,
|
||||
IGeoCodingAPI $geo_coding_api,
|
||||
IFolderService $folder_service,
|
||||
IFileUploader $file_uploader,
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->location_repository = $location_repository;
|
||||
$this->geo_coding_api = $geo_coding_api;
|
||||
$this->file_uploader = $file_uploader;
|
||||
$this->folder_service = $folder_service;
|
||||
}
|
||||
|
||||
@ -1172,8 +1175,7 @@ final class SummitLocationService
|
||||
);
|
||||
}
|
||||
|
||||
$uploader = new FileUploader($this->folder_service, new SwiftBucket);
|
||||
$pic = $uploader->build($file, sprintf('summits/%s/locations/%s/maps', $location->getSummitId(), $location->getId()), true);
|
||||
$pic = $this->file_uploader->build($file, sprintf('summits/%s/locations/%s/maps', $location->getSummitId(), $location->getId()), true);
|
||||
$map = SummitLocationImageFactory::buildMap($metadata);
|
||||
$map->setPicture($pic);
|
||||
$location->addMap($map);
|
||||
@ -1276,8 +1278,7 @@ final class SummitLocationService
|
||||
);
|
||||
}
|
||||
|
||||
$uploader = new FileUploader($this->folder_service, new SwiftBucket);
|
||||
$pic = $uploader->build($file, sprintf('summits/%s/locations/%s/maps', $location->getSummitId(), $location->getId()), true);
|
||||
$pic = $this->file_uploader->build($file, sprintf('summits/%s/locations/%s/maps', $location->getSummitId(), $location->getId()), true);
|
||||
$map->setPicture($pic);
|
||||
}
|
||||
|
||||
@ -1443,8 +1444,7 @@ final class SummitLocationService
|
||||
);
|
||||
}
|
||||
|
||||
$uploader = new FileUploader($this->folder_service, new SwiftBucket);
|
||||
$pic = $uploader->build($file, sprintf('summits/%s/locations/%s/images', $location->getSummitId(), $location->getId()), true);
|
||||
$pic = $this->file_uploader->build($file, sprintf('summits/%s/locations/%s/images', $location->getSummitId(), $location->getId()), true);
|
||||
$image = SummitLocationImageFactory::buildImage($metadata);
|
||||
$image->setPicture($pic);
|
||||
$location->addImage($image);
|
||||
@ -1547,8 +1547,7 @@ final class SummitLocationService
|
||||
);
|
||||
}
|
||||
|
||||
$uploader = new FileUploader($this->folder_service, new SwiftBucket);
|
||||
$pic = $uploader->build($file, sprintf('summits/%s/locations/%s/images', $location->getSummitId(), $location->getId()), true);
|
||||
$pic = $this->file_uploader->build($file, sprintf('summits/%s/locations/%s/images', $location->getSummitId(), $location->getId()), true);
|
||||
$image->setPicture($pic);
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,7 @@ use App\Events\MyScheduleAdd;
|
||||
use App\Events\MyScheduleRemove;
|
||||
use App\Events\SummitDeleted;
|
||||
use App\Events\SummitUpdated;
|
||||
use App\Http\Utils\FileUploader;
|
||||
use App\Http\Utils\SwiftBucket;
|
||||
use App\Http\Utils\IFileUploader;
|
||||
use App\Models\Foundation\Summit\Factories\SummitFactory;
|
||||
use App\Models\Foundation\Summit\Repositories\IDefaultSummitEventTypeRepository;
|
||||
use App\Models\Utils\IntervalParser;
|
||||
@ -167,6 +166,11 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
*/
|
||||
private $permissions_manager;
|
||||
|
||||
/**
|
||||
* @var IFileUploader
|
||||
*/
|
||||
private $file_uploader;
|
||||
|
||||
/**
|
||||
* SummitService constructor.
|
||||
* @param ISummitRepository $summit_repository
|
||||
@ -182,9 +186,10 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
* @param IEventbriteAPI $eventbrite_api
|
||||
* @param IFolderService $folder_service
|
||||
* @param ICompanyRepository $company_repository
|
||||
* @param IGroupRepository $group_repository,
|
||||
* @param IGroupRepository $group_repository
|
||||
* @param IDefaultSummitEventTypeRepository $default_event_types_repository
|
||||
* @param IPermissionsManager $permissions_manager
|
||||
* @param IFileUploader $file_uploader
|
||||
* @param ITransactionService $tx_service
|
||||
*/
|
||||
public function __construct
|
||||
@ -205,6 +210,7 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
IGroupRepository $group_repository,
|
||||
IDefaultSummitEventTypeRepository $default_event_types_repository,
|
||||
IPermissionsManager $permissions_manager,
|
||||
IFileUploader $file_uploader,
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
@ -225,6 +231,7 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
$this->group_repository = $group_repository;
|
||||
$this->default_event_types_repository = $default_event_types_repository;
|
||||
$this->permissions_manager = $permissions_manager;
|
||||
$this->file_uploader = $file_uploader;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1283,8 +1290,7 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
throw new ValidationException(sprintf( "file exceeds max_file_size (%s MB).", ($max_file_size/1024)/1024));
|
||||
}
|
||||
|
||||
$uploader = new FileUploader($this->folder_service, new SwiftBucket);
|
||||
$attachment = $uploader->build($file, 'summit-event-attachments', true);
|
||||
$attachment = $this->file_uploader->build($file, 'summit-event-attachments', true);
|
||||
$event->setAttachment($attachment);
|
||||
|
||||
return $attachment;
|
||||
|
596
composer.lock
generated
596
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -155,6 +155,7 @@ return [
|
||||
App\Repositories\RepositoriesProvider::class,
|
||||
services\ServicesProvider::class,
|
||||
factories\FactoriesProvider::class,
|
||||
App\Http\Utils\UtilsProvider::class,
|
||||
libs\utils\CustomDoctrineServiceProvider::class,
|
||||
LaravelDoctrine\Extensions\BeberleiExtensionsServiceProvider::class,
|
||||
],
|
||||
|
@ -1568,19 +1568,123 @@ class ApiEndpointsSeeder extends Seeder
|
||||
'name' => 'create-presentation-video',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/videos',
|
||||
'http_method' => 'POST',
|
||||
'scopes' => [sprintf(SummitScopes::WriteVideoData, $current_realm)],
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteVideoData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationMaterialsData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationVideosData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'update-presentation-video',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/videos/{video_id}',
|
||||
'http_method' => 'PUT',
|
||||
'scopes' => [sprintf(SummitScopes::WriteVideoData, $current_realm)],
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteVideoData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationMaterialsData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationVideosData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'delete-presentation-video',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/videos/{video_id}',
|
||||
'http_method' => 'DELETE',
|
||||
'scopes' => [sprintf(SummitScopes::WriteVideoData, $current_realm)],
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteVideoData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationMaterialsData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationVideosData, $current_realm)
|
||||
],
|
||||
],
|
||||
// links
|
||||
[
|
||||
'name' => 'get-presentation-links',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/links',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'get-presentation-link',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/links/{link_id}',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'create-presentation-link',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/links',
|
||||
'http_method' => 'POST',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WritePresentationMaterialsData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationLinksData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'update-presentation-link',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/links/{link_id}',
|
||||
'http_method' => 'PUT',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WritePresentationMaterialsData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationLinksData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'delete-presentation-link',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/links/{link_id}',
|
||||
'http_method' => 'DELETE',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WritePresentationMaterialsData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationLinksData, $current_realm)
|
||||
],
|
||||
],
|
||||
// slides
|
||||
[
|
||||
'name' => 'get-presentation-slides',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/slides',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'get-presentation-slide',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/slides/{slide_id}',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'create-presentation-slide',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/slides',
|
||||
'http_method' => 'POST',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WritePresentationMaterialsData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationSlidesData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'update-presentation-slide',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/slides/{slide_id}',
|
||||
'http_method' => 'PUT',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WritePresentationMaterialsData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationSlidesData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'delete-presentation-slide',
|
||||
'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/slides/{slide_id}',
|
||||
'http_method' => 'DELETE',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WritePresentationMaterialsData, $current_realm),
|
||||
sprintf(SummitScopes::WritePresentationSlidesData, $current_realm)
|
||||
],
|
||||
],
|
||||
//members
|
||||
[
|
||||
|
@ -166,6 +166,26 @@ final class ApiScopesSeeder extends Seeder
|
||||
'short_description' => 'Write Summit Track Question Template Data',
|
||||
'description' => 'Grants write access for Summit Track Question Template Data',
|
||||
],
|
||||
[
|
||||
'name' => sprintf(SummitScopes::WritePresentationVideosData, $current_realm),
|
||||
'short_description' => 'Write Summit Presentation Videos Data',
|
||||
'description' => 'Grants write access for Summit Presentation Videos Data',
|
||||
],
|
||||
[
|
||||
'name' => sprintf(SummitScopes::WritePresentationSlidesData, $current_realm),
|
||||
'short_description' => 'Write Summit Presentation Slides Data',
|
||||
'description' => 'Grants write access for Summit Presentation Slides Data',
|
||||
],
|
||||
[
|
||||
'name' => sprintf(SummitScopes::WritePresentationLinksData, $current_realm),
|
||||
'short_description' => 'Write Summit Presentation Links Data',
|
||||
'description' => 'Grants write access for Summit Presentation Links Data',
|
||||
],
|
||||
[
|
||||
'name' => sprintf(SummitScopes::WritePresentationMaterialsData, $current_realm),
|
||||
'short_description' => 'Write Summit Presentation Materials Data',
|
||||
'description' => 'Grants write access for Summit Materials Links Data',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($scopes as $scope_info) {
|
||||
|
@ -12,13 +12,34 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
use LaravelDoctrine\ORM\Facades\EntityManager;
|
||||
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
/**
|
||||
* Class OAuth2SummitApiTest
|
||||
*/
|
||||
final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
{
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
Mockery::close();
|
||||
}
|
||||
|
||||
public function createApplication()
|
||||
{
|
||||
$app = parent::createApplication();
|
||||
|
||||
$fileUploaderMock = Mockery::mock(\App\Http\Utils\IFileUploader::class)
|
||||
->shouldIgnoreMissing();
|
||||
|
||||
$fileUploaderMock->shouldReceive('build')->andReturn(new \models\main\File());
|
||||
|
||||
$app->instance(\App\Http\Utils\IFileUploader::class, $fileUploaderMock);
|
||||
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
public function testGetSummits()
|
||||
{
|
||||
|
||||
@ -902,12 +923,15 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertTrue(!is_null($attendee));
|
||||
}
|
||||
|
||||
public function testAddPresentationVideo($summit_id = 7, $presentation_id = 15404)
|
||||
public function testAddPresentationVideo($summit_id = 25)
|
||||
{
|
||||
$repo = EntityManager::getRepository(\models\summit\Summit::class);
|
||||
$summit = $repo->getById($summit_id);
|
||||
$presentation = $summit->getPublishedPresentations()[0];
|
||||
$params = array
|
||||
(
|
||||
'id' => $summit_id,
|
||||
'presentation_id' => $presentation_id
|
||||
'presentation_id' => $presentation->getId()
|
||||
);
|
||||
|
||||
$headers = array
|
||||
@ -943,7 +967,7 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
|
||||
public function testUpdatePresentationVideo()
|
||||
{
|
||||
$video_id = $this->testAddPresentationVideo(7, 15404);
|
||||
$video_id = $this->testAddPresentationVideo($summit_id = 25);
|
||||
|
||||
$params = array
|
||||
(
|
||||
@ -1017,7 +1041,7 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
|
||||
public function testDeletePresentationVideo()
|
||||
{
|
||||
$video_id = $this->testAddPresentationVideo(7, 15404);
|
||||
$video_id = $this->testAddPresentationVideo($summit_id = 25);
|
||||
|
||||
$params = array
|
||||
(
|
||||
@ -1243,5 +1267,47 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
}
|
||||
|
||||
|
||||
public function testAddPresentationSlide($summit_id=25){
|
||||
|
||||
$repo = EntityManager::getRepository(\models\summit\Summit::class);
|
||||
$summit = $repo->getById($summit_id);
|
||||
$presentation = $summit->getPublishedPresentations()[0];
|
||||
$params = array
|
||||
(
|
||||
'id' => $summit_id,
|
||||
'presentation_id' => $presentation->getId(),
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$video_data = array
|
||||
(
|
||||
'name' => 'test slide',
|
||||
'description' => 'test slide',
|
||||
'display_on_site' => true,
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"POST",
|
||||
"OAuth2PresentationApiController@addPresentationSlide",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
[
|
||||
'file' => UploadedFile::fake()->image('slide.pdf')
|
||||
],
|
||||
$headers,
|
||||
json_encode($video_data)
|
||||
);
|
||||
|
||||
$video_id = $response->getContent();
|
||||
$this->assertResponseStatus(201);
|
||||
return intval($video_id);
|
||||
}
|
||||
|
||||
}
|
@ -66,6 +66,7 @@ class AccessTokenServiceStub implements IAccessTokenService
|
||||
sprintf(SummitScopes::WritePromoCodeData, $url),
|
||||
sprintf(OrganizationScopes::WriteOrganizationData, $url),
|
||||
sprintf(OrganizationScopes::ReadOrganizationData, $url),
|
||||
sprintf(SummitScopes::WritePresentationMaterialsData, $url),
|
||||
);
|
||||
|
||||
return AccessToken::createFromParams('123456789', implode(' ', $scopes), '1', $realm, '1','11624', 3600, 'WEB_APPLICATION', '', '');
|
||||
@ -113,10 +114,11 @@ class AccessTokenServiceStub2 implements IAccessTokenService
|
||||
sprintf(SummitScopes::WriteSpeakersData, $url),
|
||||
sprintf(SummitScopes::WriteMySpeakersData, $url),
|
||||
sprintf(SummitScopes::WriteAttendeesData, $url),
|
||||
sprintf(Mem::WriteMemberData, $url),
|
||||
sprintf(MemberScopes::WriteMemberData, $url),
|
||||
sprintf(SummitScopes::WritePromoCodeData, $url),
|
||||
sprintf(OrganizationScopes::WriteOrganizationData, $url),
|
||||
sprintf(OrganizationScopes::ReadOrganizationData, $url),
|
||||
sprintf(SummitScopes::WritePresentationMaterialsData, $url),
|
||||
);
|
||||
|
||||
return AccessToken::createFromParams('123456789', implode(' ', $scopes), '1', $realm, null,null, 3600, 'SERVICE', '', '');
|
||||
|
Loading…
x
Reference in New Issue
Block a user