Fix on Admin Speaker Serializer
Added all presentation collection Change-Id: I38448e850526063885c6f041c1840ed4adc33fc7
This commit is contained in:
parent
ce237b5b16
commit
d349f4d684
@ -458,7 +458,7 @@ final class OAuth2SummitSpeakersApiController extends OAuth2ProtectedController
|
||||
return $this->error412(array('file param not set!'));
|
||||
}
|
||||
|
||||
$res = $this->service->addSpeakerAttachment($speaker_id, $file);
|
||||
$res = $this->service->addSpeakerPhoto($speaker_id, $file);
|
||||
|
||||
return !is_null($res) ? $this->created($res->getId()) : $this->error400();
|
||||
}
|
||||
|
@ -35,10 +35,11 @@ final class FileUploader
|
||||
|
||||
/**
|
||||
* @param UploadedFile $file
|
||||
* @param $folder_name
|
||||
* @param string $folder_name
|
||||
* @param bool $is_image
|
||||
* @return File
|
||||
*/
|
||||
public function build(UploadedFile $file, $folder_name){
|
||||
public function build(UploadedFile $file, $folder_name, $is_image = false){
|
||||
$attachment = new File();
|
||||
$local_path = Storage::putFileAs(sprintf('/public/%s', $folder_name), $file, $file->getClientOriginalName());
|
||||
$folder = $this->folder_repository->getFolderByName($folder_name);
|
||||
@ -47,6 +48,8 @@ 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();
|
||||
Event::fire(new FileCreated($local_path, $file->getClientOriginalName(), $folder_name));
|
||||
return $attachment;
|
||||
}
|
||||
|
@ -48,6 +48,27 @@ final class AdminPresentationSpeakerSerializer extends PresentationSpeakerSerial
|
||||
$values['registration_code'] = SerializerRegistry::getInstance()->getSerializer($registration_code)->serialize();
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($expand)) {
|
||||
foreach (explode(',', $expand) as $relation) {
|
||||
switch (trim($relation)) {
|
||||
case 'presentations': {
|
||||
$presentations = [];
|
||||
foreach ($speaker->getPresentations($summit->getId(), false) as $p) {
|
||||
$presentations[] = SerializerRegistry::getInstance()->getSerializer($p)->serialize();
|
||||
}
|
||||
$values['all_presentations'] = $presentations;
|
||||
|
||||
$moderated_presentations = [];
|
||||
foreach ($speaker->getModeratedPresentations($summit->getId(), false) as $p) {
|
||||
$moderated_presentations[] = SerializerRegistry::getInstance()->getSerializer($p)->serialize();
|
||||
}
|
||||
$values['all_moderated_presentations'] = $presentations;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ use DateTime;
|
||||
class AssetsSyncRequest extends SilverstripeBaseModel
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="`Source`", type="string")
|
||||
* @ORM\Column(name="`Origin`", type="string")
|
||||
*/
|
||||
private $from;
|
||||
|
||||
|
@ -31,6 +31,11 @@ class File extends SilverstripeBaseModel
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ClassName", type="string")
|
||||
*/
|
||||
private $class_name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Content", type="string")
|
||||
*/
|
||||
@ -172,4 +177,14 @@ class File extends SilverstripeBaseModel
|
||||
{
|
||||
$this->owner = $owner;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->class_name = 'File';
|
||||
}
|
||||
|
||||
public function setImage(){
|
||||
$this->class_name = 'Image';
|
||||
}
|
||||
}
|
@ -58,5 +58,5 @@ interface ISpeakerService
|
||||
* @throws EntityNotFoundException
|
||||
* @return File
|
||||
*/
|
||||
public function addSpeakerAttachment($speaker_id, UploadedFile $file, $max_file_size = 10485760);
|
||||
public function addSpeakerPhoto($speaker_id, UploadedFile $file, $max_file_size = 10485760);
|
||||
}
|
@ -349,7 +349,7 @@ final class SpeakerService implements ISpeakerService
|
||||
* @throws EntityNotFoundException
|
||||
* @return File
|
||||
*/
|
||||
public function addSpeakerAttachment($speaker_id, UploadedFile $file, $max_file_size = 10485760)
|
||||
public function addSpeakerPhoto($speaker_id, UploadedFile $file, $max_file_size = 10485760)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($speaker_id, $file, $max_file_size) {
|
||||
|
||||
@ -371,7 +371,7 @@ final class SpeakerService implements ISpeakerService
|
||||
}
|
||||
|
||||
$uploader = new FileUploader($this->folder_repository);
|
||||
$photo = $uploader->build($file, 'profile-images');
|
||||
$photo = $uploader->build($file, 'profile-images', true);
|
||||
$speaker->setPhoto($photo);
|
||||
|
||||
return $photo;
|
||||
|
@ -1207,7 +1207,7 @@ final class SummitService implements ISummitService
|
||||
}
|
||||
|
||||
$uploader = new FileUploader($this->folder_repository);
|
||||
$attachment = $uploader->build($file, 'summit-event-attachments');
|
||||
$attachment = $uploader->build($file, 'summit-event-attachments', true);
|
||||
$event->setAttachment($attachment);
|
||||
|
||||
return $attachment;
|
||||
|
Loading…
x
Reference in New Issue
Block a user