openstackid-resources/app/Factories/EntityEvents/TrackGroupActionActionEntityEventFactory.php
smarcet f1b4ce63ff Updated Resource Server Context to retrive User
by external user

this is a change required after this update

https://review.opendev.org/#/c/661661/

Change-Id: I13283c0a491ffb924d67bdeac84b5adcf3afe45c
2019-07-28 18:14:19 -03:00

52 lines
1.9 KiB
PHP

<?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\TrackGroupAction;
use Illuminate\Support\Facades\App;
use models\main\IMemberRepository;
use models\oauth2\IResourceServerContext;
use models\summit\ISummitRepository;
use models\summit\SummitEntityEvent;
/**
* Class TrackGroupActionActionEntityEventFactory
* @package App\Factories\EntityEvents
*/
final class TrackGroupActionActionEntityEventFactory
{
/**
* @param TrackGroupAction $event
* @param string $type
* @return SummitEntityEvent
*/
public static function build(TrackGroupAction $event, $type = 'UPDATE')
{
$resource_server_context = App::make(IResourceServerContext::class);
$summit_repository = App::make(ISummitRepository::class);
$summit = $summit_repository->getById($event->getSummitId());
$owner = $resource_server_context->getCurrentUser();
$entity_event = new SummitEntityEvent;
$entity_event->setEntityClassName($event->getClassName());
$entity_event->setEntityId($event->getTrackGroupId());
$entity_event->setType($type);
if (!is_null($owner)) {
$entity_event->setOwner($owner);
}
$entity_event->setSummit($summit);
$entity_event->setMetadata('');
return $entity_event;
}
}