Added enpoint update summit venue floor
PUT /api/v1/summits/{id}/locations/venues/{venue_id}/floors/{floor_id} Payload * name (sometimes|string|max:50) * number (sometimes|integer) * description (sometimes|string) Change-Id: I575680d5f32814393eeac655d55227dd1cae349a
This commit is contained in:
parent
b66129b7cd
commit
19161fb734
72
app/Events/FloorAction.php
Normal file
72
app/Events/FloorAction.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 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\Queue\SerializesModels;
|
||||
/**
|
||||
* Class FloorAction
|
||||
* @package App\Events
|
||||
*/
|
||||
class FloorAction
|
||||
{
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $floor_id;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $venue_id;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $summit_id;
|
||||
|
||||
/**
|
||||
* FloorAction constructor.
|
||||
* @param int $summit_id
|
||||
* @param int $venue_id
|
||||
* @param int $floor_id
|
||||
*/
|
||||
public function __construct($summit_id, $venue_id, $floor_id)
|
||||
{
|
||||
$this->summit_id = $summit_id;
|
||||
$this->venue_id = $venue_id;
|
||||
$this->floor_id = $floor_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFloorId()
|
||||
{
|
||||
return $this->floor_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getVenueId()
|
||||
{
|
||||
return $this->venue_id;
|
||||
}
|
||||
|
||||
public function getSummitId(){
|
||||
return $this->summit_id;
|
||||
}
|
||||
|
||||
}
|
22
app/Events/FloorDeleted.php
Normal file
22
app/Events/FloorDeleted.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 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.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class FloorDeleted
|
||||
* @package App\Events
|
||||
*/
|
||||
final class FloorDeleted extends FloorAction
|
||||
{
|
||||
|
||||
}
|
22
app/Events/FloorInserted.php
Normal file
22
app/Events/FloorInserted.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 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.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class FloorInserted
|
||||
* @package App\Events
|
||||
*/
|
||||
final class FloorInserted extends FloorAction
|
||||
{
|
||||
|
||||
}
|
22
app/Events/FloorUpdated.php
Normal file
22
app/Events/FloorUpdated.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 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.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class FloorUpdated
|
||||
* @package App\Events
|
||||
*/
|
||||
final class FloorUpdated extends FloorAction
|
||||
{
|
||||
|
||||
}
|
75
app/Events/SummitEventTypeAction.php
Normal file
75
app/Events/SummitEventTypeAction.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 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\Queue\SerializesModels;
|
||||
/**
|
||||
* Class SummitEventTypeAction
|
||||
* @package App\Events
|
||||
*/
|
||||
class SummitEventTypeAction
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $event_type_id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $class_name;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $summit_id;
|
||||
|
||||
/**
|
||||
* SummitEventTypeAction constructor.
|
||||
* @param int $event_type_id
|
||||
* @param string $class_name
|
||||
* @param int $summit_id
|
||||
*/
|
||||
public function __construct($event_type_id, $class_name, $summit_id)
|
||||
{
|
||||
$this->event_type_id = $event_type_id;
|
||||
$this->class_name = $class_name;
|
||||
$this->summit_id = $summit_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getEventTypeId()
|
||||
{
|
||||
return $this->event_type_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return $this->class_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSummitId()
|
||||
{
|
||||
return $this->summit_id;
|
||||
}
|
||||
|
||||
}
|
18
app/Events/SummitEventTypeDeleted.php
Normal file
18
app/Events/SummitEventTypeDeleted.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 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.
|
||||
**/
|
||||
|
||||
final class SummitEventTypeDeleted extends SummitEventTypeAction
|
||||
{
|
||||
|
||||
}
|
22
app/Events/SummitEventTypeInserted.php
Normal file
22
app/Events/SummitEventTypeInserted.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 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.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class SummitEventTypeInserted
|
||||
* @package App\Events
|
||||
*/
|
||||
final class SummitEventTypeInserted extends SummitEventTypeAction
|
||||
{
|
||||
|
||||
}
|
22
app/Events/SummitEventTypeUpdated.php
Normal file
22
app/Events/SummitEventTypeUpdated.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 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.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class SummitEventTypeUpdated
|
||||
* @package App\Events
|
||||
*/
|
||||
final class SummitEventTypeUpdated extends SummitEventTypeAction
|
||||
{
|
||||
|
||||
}
|
59
app/Factories/EntityEvents/FloorActionEntityEventFactory.php
Normal file
59
app/Factories/EntityEvents/FloorActionEntityEventFactory.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php namespace App\Factories\EntityEvents;
|
||||
/**
|
||||
* Copyright 2018 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 App\Events\FloorAction;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use models\main\IMemberRepository;
|
||||
use models\oauth2\IResourceServerContext;
|
||||
use models\summit\ISummitRepository;
|
||||
use models\summit\SummitEntityEvent;
|
||||
use models\summit\SummitVenueFloor;
|
||||
/**
|
||||
* Class FloorActionEntityEventFactory
|
||||
* @package App\Factories\EntityEvents
|
||||
*/
|
||||
final class FloorActionEntityEventFactory
|
||||
{
|
||||
/**
|
||||
* @param FloorAction $event
|
||||
* @param string $type
|
||||
* @return SummitEntityEvent
|
||||
*/
|
||||
public static function build(FloorAction $event, $type = 'UPDATE')
|
||||
{
|
||||
$resource_server_context = App::make(IResourceServerContext::class);
|
||||
$member_repository = App::make(IMemberRepository::class);
|
||||
$summit_repository = App::make(ISummitRepository::class);
|
||||
$summit = $summit_repository->getById($event->getSummitId());
|
||||
$owner_id = $resource_server_context->getCurrentUserExternalId();
|
||||
|
||||
if (is_null($owner_id)) $owner_id = 0;
|
||||
|
||||
$entity_event = new SummitEntityEvent;
|
||||
$entity_event->setEntityClassName('SummitVenueFloor');
|
||||
$entity_event->setEntityId($event->getFloorId());
|
||||
$entity_event->setType($type);
|
||||
|
||||
if ($owner_id > 0) {
|
||||
$member = $member_repository->getById($owner_id);
|
||||
$entity_event->setOwner($member);
|
||||
}
|
||||
|
||||
$entity_event->setSummit($summit);
|
||||
$entity_event->setMetadata(json_encode([
|
||||
'venue_id' => $event->getVenueId()
|
||||
]));
|
||||
|
||||
return $entity_event;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
<?php namespace App\Factories\EntityEvents;
|
||||
/**
|
||||
* Copyright 2018 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 App\Events\SummitEventTypeAction;
|
||||
use models\main\IMemberRepository;
|
||||
use models\oauth2\IResourceServerContext;
|
||||
use models\summit\ISummitRepository;
|
||||
use models\summit\SummitEntityEvent;
|
||||
|
||||
/**
|
||||
* Class SummitEventTypeActionEntityEventFactory
|
||||
* @package App\Factories\EntityEvents
|
||||
*/
|
||||
final class SummitEventTypeActionEntityEventFactory
|
||||
{
|
||||
/**
|
||||
* @param SummitEventTypeAction $event
|
||||
* @param string $type
|
||||
* @return SummitEntityEvent
|
||||
*/
|
||||
public static function build(SummitEventTypeAction $event, $type = 'UPDATE')
|
||||
{
|
||||
$resource_server_context = App::make(IResourceServerContext::class);
|
||||
$member_repository = App::make(IMemberRepository::class);
|
||||
$summit_repository = App::make(ISummitRepository::class);
|
||||
$summit = $summit_repository->getById($event->getSummitId());
|
||||
|
||||
$owner_id = $resource_server_context->getCurrentUserExternalId();
|
||||
if (is_null($owner_id)) $owner_id = 0;
|
||||
|
||||
|
||||
$entity_event = new SummitEntityEvent;
|
||||
$entity_event->setEntityClassName($event->getClassName());
|
||||
$entity_event->setEntityId($event->getEventTypeId());
|
||||
$entity_event->setType($type);
|
||||
|
||||
if ($owner_id > 0) {
|
||||
$member = $member_repository->getById($owner_id);
|
||||
$entity_event->setOwner($member);
|
||||
}
|
||||
|
||||
$entity_event->setSummit($summit);
|
||||
$entity_event->setMetadata('');
|
||||
|
||||
return $entity_event;
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ final class TrackActionEntityEventFactory
|
||||
|
||||
|
||||
$entity_event = new SummitEntityEvent;
|
||||
$entity_event->setEntityClassName(PresentationCategory::class);
|
||||
$entity_event->setEntityClassName('PresentationCategory');
|
||||
$entity_event->setEntityId($event->getTrackId());
|
||||
$entity_event->setType($type);
|
||||
|
||||
|
@ -937,6 +937,56 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $venue_id
|
||||
* @param $floor_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function updateVenueFloor($summit_id, $venue_id, $floor_id){
|
||||
try {
|
||||
if(!Request::isJson()) return $this->error403();
|
||||
$payload = Input::json()->all();
|
||||
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
$payload['class_name'] = SummitAirport::ClassName;
|
||||
$rules = [
|
||||
'name' => 'sometimes|string|max:50',
|
||||
'number' => 'sometimes|integer',
|
||||
'description' => 'sometimes|string',
|
||||
];
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($payload, $rules);
|
||||
|
||||
if ($validation->fails()) {
|
||||
$messages = $validation->messages()->toArray();
|
||||
|
||||
return $this->error412
|
||||
(
|
||||
$messages
|
||||
);
|
||||
}
|
||||
|
||||
$floor = $this->location_service->updateVenueFloor($summit, $venue_id, $floor_id, $payload);
|
||||
|
||||
return $this->updated(SerializerRegistry::getInstance()->getSerializer($floor)->serialize());
|
||||
}
|
||||
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 $hotel_id
|
||||
@ -1108,4 +1158,8 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteVenueFloor($summit_id, $venue_id, $floor_id){
|
||||
|
||||
}
|
||||
}
|
@ -293,8 +293,11 @@ Route::group([
|
||||
|
||||
Route::group(['prefix' => 'floors'], function () {
|
||||
Route::post('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitLocationsApiController@addVenueFloor']);
|
||||
Route::group(['prefix' => '{floor_id}'], function () {
|
||||
Route::put('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitLocationsApiController@updateVenueFloor']);
|
||||
Route::delete('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitLocationsApiController@deleteVenueFloor']);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -19,6 +19,7 @@ use App\Factories\AssetsSyncRequest\FileCreatedAssetSyncRequestFactory;
|
||||
use App\Factories\CalendarAdminActionSyncWorkRequest\AdminSummitLocationActionSyncWorkRequestFactory;
|
||||
use App\Factories\CalendarAdminActionSyncWorkRequest\SummitEventDeletedCalendarSyncWorkRequestFactory;
|
||||
use App\Factories\CalendarAdminActionSyncWorkRequest\SummitEventUpdatedCalendarSyncWorkRequestFactory;
|
||||
use App\Factories\EntityEvents\FloorActionEntityEventFactory;
|
||||
use App\Factories\EntityEvents\LocationActionEntityEventFactory;
|
||||
use App\Factories\EntityEvents\MyFavoritesAddEntityEventFactory;
|
||||
use App\Factories\EntityEvents\MyFavoritesRemoveEntityEventFactory;
|
||||
@ -32,6 +33,7 @@ use App\Factories\EntityEvents\PresentationSpeakerDeletedEntityEventFactory;
|
||||
use App\Factories\EntityEvents\PresentationSpeakerUpdatedEntityEventFactory;
|
||||
use App\Factories\EntityEvents\SummitEventCreatedEntityEventFactory;
|
||||
use App\Factories\EntityEvents\SummitEventDeletedEntityEventFactory;
|
||||
use App\Factories\EntityEvents\SummitEventTypeActionEntityEventFactory;
|
||||
use App\Factories\EntityEvents\SummitEventUpdatedEntityEventFactory;
|
||||
use App\Factories\EntityEvents\TrackActionEntityEventFactory;
|
||||
use App\Services\Utils\SCPFileUploader;
|
||||
@ -138,6 +140,23 @@ final class EventServiceProvider extends ServiceProvider
|
||||
EntityEventPersister::persist_list(PresentationSpeakerDeletedEntityEventFactory::build($event));
|
||||
});
|
||||
|
||||
// event types
|
||||
|
||||
Event::listen(\App\Events\SummitEventTypeInserted::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(SummitEventTypeActionEntityEventFactory::build($event, 'INSERT'));
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\SummitEventTypeUpdated::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(SummitEventTypeActionEntityEventFactory::build($event, 'UPDATE'));
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\SummitEventTypeDeleted::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(SummitEventTypeActionEntityEventFactory::build($event, 'DELETE'));
|
||||
});
|
||||
|
||||
// tracks
|
||||
|
||||
Event::listen(\App\Events\TrackInserted::class, function($event)
|
||||
@ -186,5 +205,21 @@ final class EventServiceProvider extends ServiceProvider
|
||||
}
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\FloorInserted::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(FloorActionEntityEventFactory::build($event, 'INSERT'));
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\FloorUpdated::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(FloorActionEntityEventFactory::build($event, 'UPDATE'));
|
||||
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\FloorDeleted::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(FloorActionEntityEventFactory::build($event, 'DELETE'));
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Events\FloorInserted;
|
||||
use App\Events\FloorUpdated;
|
||||
use App\Events\LocationDeleted;
|
||||
use App\Events\LocationInserted;
|
||||
use App\Events\LocationUpdated;
|
||||
@ -310,16 +312,16 @@ final class LocationService implements ILocationService
|
||||
*/
|
||||
public function addVenueFloor(Summit $summit, $venue_id, array $data)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($summit, $venue_id, $data) {
|
||||
$floor = $this->tx_service->transaction(function () use ($summit, $venue_id, $data) {
|
||||
|
||||
$venue = $summit->getLocation($venue_id);
|
||||
|
||||
if(is_null($venue)){
|
||||
throw new ValidationException
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'validation_errors.LocationService.addVenueFloor.VenueNotFound',
|
||||
'not_found_errors.LocationService.addVenueFloor.VenueNotFound',
|
||||
[
|
||||
'summit_id' => $summit->getId(),
|
||||
'venue_id' => $venue_id,
|
||||
@ -379,6 +381,18 @@ final class LocationService implements ILocationService
|
||||
|
||||
return $floor;
|
||||
});
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new FloorInserted
|
||||
(
|
||||
$floor->getVenue()->getSummitId(),
|
||||
$floor->getVenueId(),
|
||||
$floor->getId()
|
||||
)
|
||||
);
|
||||
|
||||
return $floor;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -393,7 +407,100 @@ final class LocationService implements ILocationService
|
||||
public function updateVenueFloor(Summit $summit, $venue_id, $floor_id, array $data)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($summit, $venue_id, $floor_id, $data) {
|
||||
$venue = $summit->getLocation($venue_id);
|
||||
|
||||
if(is_null($venue)){
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.LocationService.updateVenueFloor.VenueNotFound',
|
||||
[
|
||||
'summit_id' => $summit->getId(),
|
||||
'venue_id' => $venue_id,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if(!$venue instanceof SummitVenue){
|
||||
throw new ValidationException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'validation_errors.LocationService.updateVenueFloor.VenueNotFound',
|
||||
[
|
||||
'summit_id' => $summit->getId(),
|
||||
'venue_id' => $venue_id,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if(isset($data['name'])) {
|
||||
$former_floor = $venue->getFloorByName(trim($data['name']));
|
||||
|
||||
if (!is_null($former_floor) && $former_floor->getId() != $floor_id) {
|
||||
throw new ValidationException(
|
||||
trans
|
||||
(
|
||||
'validation_errors.LocationService.addVenueFloor.FloorNameAlreadyExists',
|
||||
[
|
||||
'venue_id' => $venue_id,
|
||||
'floor_name' => trim($data['name'])
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['number'])) {
|
||||
$former_floor = $venue->getFloorByNumber(intval($data['number']));
|
||||
|
||||
if (!is_null($former_floor) && $former_floor->getId() != $floor_id) {
|
||||
throw new ValidationException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'validation_errors.LocationService.addVenueFloor.FloorNumberAlreadyExists',
|
||||
[
|
||||
'venue_id' => $venue_id,
|
||||
'floor_number' => intval($data['number'])
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$floor = $venue->getFloor($floor_id);
|
||||
if(is_null($floor)){
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.LocationService.updateVenueFloor.FloorNotFound',
|
||||
[
|
||||
'floor_id' => $floor_id,
|
||||
'venue_id' => $venue_id
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$floor = SummitVenueFloorFactory::populate($floor, $data);
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new FloorUpdated
|
||||
(
|
||||
$floor->getVenue()->getSummitId(),
|
||||
$floor->getVenueId(),
|
||||
$floor->getId()
|
||||
)
|
||||
);
|
||||
|
||||
return $floor;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -11,10 +11,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Events\SummitEventTypeDeleted;
|
||||
use App\Events\SummitEventTypeInserted;
|
||||
use App\Events\SummitEventTypeUpdated;
|
||||
use App\Models\Foundation\Summit\Factories\SummitEventTypeFactory;
|
||||
use App\Models\Foundation\Summit\Repositories\IDefaultSummitEventTypeRepository;
|
||||
use App\Models\Foundation\Summit\Repositories\ISummitEventTypeRepository;
|
||||
use App\Services\Model\ISummitEventTypeService;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use libs\utils\ITransactionService;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
@ -69,7 +73,7 @@ final class SummitEventTypeService implements ISummitEventTypeService
|
||||
*/
|
||||
public function addEventType(Summit $summit, array $data)
|
||||
{
|
||||
return $this->tx_service->transaction(function() use($summit, $data){
|
||||
$event_type = $this->tx_service->transaction(function() use($summit, $data){
|
||||
|
||||
$type = trim($data['name']);
|
||||
|
||||
@ -85,6 +89,18 @@ final class SummitEventTypeService implements ISummitEventTypeService
|
||||
return $event_type;
|
||||
|
||||
});
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new SummitEventTypeInserted
|
||||
(
|
||||
$event_type->getId(),
|
||||
$event_type->getClassName(),
|
||||
$event_type->getSummitId()
|
||||
)
|
||||
);
|
||||
|
||||
return $event_type;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,6 +131,16 @@ final class SummitEventTypeService implements ISummitEventTypeService
|
||||
|
||||
$event_type = SummitEventTypeFactory::populate($event_type, $summit, $data);
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new SummitEventTypeUpdated
|
||||
(
|
||||
$event_type->getId(),
|
||||
$event_type->getClassName(),
|
||||
$event_type->getSummitId()
|
||||
)
|
||||
);
|
||||
|
||||
return $event_type;
|
||||
|
||||
});
|
||||
@ -154,6 +180,16 @@ final class SummitEventTypeService implements ISummitEventTypeService
|
||||
);
|
||||
}
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new SummitEventTypeDeleted
|
||||
(
|
||||
$event_type->getId(),
|
||||
$event_type->getClassName(),
|
||||
$event_type->getSummitId()
|
||||
)
|
||||
);
|
||||
|
||||
$summit->removeEventType($event_type);
|
||||
|
||||
});
|
||||
@ -167,7 +203,7 @@ final class SummitEventTypeService implements ISummitEventTypeService
|
||||
*/
|
||||
public function seedDefaultEventTypes(Summit $summit)
|
||||
{
|
||||
return $this->tx_service->transaction(function() use($summit){
|
||||
$added_types = $this->tx_service->transaction(function() use($summit){
|
||||
$added_types = [];
|
||||
$default_types = $this->default_event_types_repository->getAll();
|
||||
foreach ($default_types as $default_type){
|
||||
@ -180,5 +216,19 @@ final class SummitEventTypeService implements ISummitEventTypeService
|
||||
|
||||
return $added_types;
|
||||
});
|
||||
|
||||
foreach ($added_types as $event_type){
|
||||
Event::fire
|
||||
(
|
||||
new SummitEventTypeInserted
|
||||
(
|
||||
$event_type->getId(),
|
||||
$event_type->getClassName(),
|
||||
$event_type->getSummitId()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $added_types;
|
||||
}
|
||||
}
|
@ -16,4 +16,8 @@ return [
|
||||
'promo_code_email_code_not_found' => 'promo code id :promo_code_id does not belongs to summit id :summit_id.',
|
||||
'add_speaker_assistance_speaker_not_found' => 'speaker id :speaker_id not found',
|
||||
'send_speaker_summit_assistance_announcement_mail_not_found_assistance' => 'summit speaker assistance :assistance_id not found for summit id :summit_id',
|
||||
// LocationService
|
||||
'LocationService.addVenueFloor.VenueNotFound' => 'venue :venue_id not found on summit :summit_id',
|
||||
'LocationService.updateVenueFloor.FloorNotFound' => 'floor :floor_id does not belongs to venue :venue_id',
|
||||
'LocationService.updateVenueFloor.VenueNotFound' => 'venue :venue_id not found on summit :summit_id',
|
||||
];
|
@ -26,6 +26,7 @@ return [
|
||||
'send_speaker_summit_assistance_announcement_mail_code_already_redeemed' => 'promo code :promo_code already redeemed.',
|
||||
'send_speaker_summit_assistance_announcement_mail_invalid_mail_type' => 'mail type :mail_type is not valid.',
|
||||
'send_speaker_summit_assistance_promo_code_not_set' => 'speaker :speaker_id has not set a promo code for summit :summit_id, please set one manually.',
|
||||
// LocationService
|
||||
'LocationService.addLocation.LocationNameAlreadyExists' => 'there is already another location with same name for summit :summit_id',
|
||||
'LocationService.addLocation.InvalidClassName' => 'invalid class name',
|
||||
'LocationService.addLocation.InvalidAddressOrCoordinates' => 'was passed a non-existent address',
|
||||
@ -34,7 +35,8 @@ return [
|
||||
'LocationService.updateLocation.LocationNameAlreadyExists' => 'there is already another location with same name for summit :summit_id',
|
||||
'LocationService.updateLocation.LocationNotFoundOnSummit' => 'location :location_id not found on summit :summit_id',
|
||||
'LocationService.updateLocation.ClassNameMissMatch' => 'location :location_id on summit :summit_id does not belongs to class name :class_name',
|
||||
'LocationService.addVenueFloor.VenueNotFound' => 'venue :venue_id not found on summit :summit_id',
|
||||
'LocationService.addVenueFloor.FloorNameAlreadyExists' => 'floor name :floor_name already belongs to another floor on venue :venue_id',
|
||||
'LocationService.addVenueFloor.FloorNumberAlreadyExists' => 'floor number :floor_number already belongs to another floor on venue :venue_id',
|
||||
'LocationService.updateVenueFloor.FloorNameAlreadyExists' => 'floor name :floor_name already belongs to another floor on venue :venue_id',
|
||||
'LocationService.updateVenueFloor.FloorNumberAlreadyExists' => 'floor number :floor_number already belongs to another floor on venue :venue_id',
|
||||
];
|
@ -691,17 +691,23 @@ final class OAuth2SummitLocationsApiTest extends ProtectedApiTest
|
||||
$this->assertResponseStatus(204);
|
||||
}
|
||||
|
||||
public function testAddVenueFloor($summit_id = 23, $venue_id = 292){
|
||||
/**
|
||||
* @param int $summit_id
|
||||
* @param int $venue_id
|
||||
* @param int $number
|
||||
* @return mixed
|
||||
*/
|
||||
public function testAddVenueFloor($summit_id = 23, $venue_id = 292, $number = 0){
|
||||
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
'venue_id' => $venue_id
|
||||
];
|
||||
|
||||
$name = str_random(16).'_floor';
|
||||
$data = [
|
||||
'name' => 'test floor',
|
||||
'name' => $name,
|
||||
'description' => 'test floor',
|
||||
'number' => -1
|
||||
'number' => $number
|
||||
];
|
||||
|
||||
$headers = [
|
||||
@ -726,4 +732,41 @@ final class OAuth2SummitLocationsApiTest extends ProtectedApiTest
|
||||
$this->assertTrue(!is_null($floor));
|
||||
return $floor;
|
||||
}
|
||||
|
||||
public function testUpdateVenueFloor($summit_id = 23, $venue_id = 292){
|
||||
|
||||
$floor = $this->testAddVenueFloor($summit_id, $venue_id, 50);
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
'venue_id' => $venue_id,
|
||||
'floor_id' => $floor->id
|
||||
];
|
||||
|
||||
$data = [
|
||||
'name' => 'test floor update',
|
||||
'description' => 'test floor update',
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"PUT",
|
||||
"OAuth2SummitLocationsApiController@updateVenueFloor",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers,
|
||||
json_encode($data)
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(201);
|
||||
$floor = json_decode($content);
|
||||
$this->assertTrue(!is_null($floor));
|
||||
return $floor;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user