Fix validation issue on links presentation creation

Change-Id: I64930ba1644cd27dd1ec8b29cb2d5c573ec0d85d
This commit is contained in:
Sebastian Marcet 2018-09-25 10:37:09 -03:00
parent ca60f492df
commit 7492438d7a
4 changed files with 13 additions and 1 deletions

View File

@ -282,7 +282,7 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
'type_id' => 'required|integer',
'track_id' => 'required|integer',
'attending_media' => 'required|boolean',
'links' => 'required|url_array',
'links' => 'sometimes|url_array',
'extra_questions' => 'sometimes|entity_value_array',
];

View File

@ -69,6 +69,8 @@ class Presentation extends SummitEvent
const ClassNamePresentation = 'Presentation';
const MaxAllowedLinks = 5;
/**
* @ORM\Column(name="Level", type="string")
* @var string

View File

@ -371,6 +371,15 @@ final class PresentationService
if (isset($data['links'])) {
$presentation->clearLinks();
if(count($data['links']) > Presentation::MaxAllowedLinks){
throw new ValidationException(trans(
'validation_errors.PresentationService.saveOrUpdatePresentation.MaxAllowedLinks',
[
'max_allowed_links' => Presentation::MaxAllowedLinks
]));
}
foreach ($data['links'] as $link) {
$presentationLink = new PresentationLink();
$presentationLink->setName(trim($link));

View File

@ -83,6 +83,7 @@ return [
'PresentationService.saveOrUpdatePresentation.notAvailableCFP' => 'type id :type_id is not a available for CFP',
'PresentationService.saveOrUpdatePresentation.trackDontBelongToSelectionPlan' => 'track :track_id does not belongs to selection plan :selection_plan_id',
'PresentationService.submitPresentation.limitReached' => 'You reached the limit :limit of presentations.',
'PresentationService.saveOrUpdatePresentation.MaxAllowedLinks' => 'max. links quantity allowed is :max_allowed_links.',
// organizations
'OrganizationService.addOrganization.alreadyExistName' => 'Organization name :name already exists!',
// track tag groups