Added endpoints
PUBLIC GET api/public/v1/summits/{id}/events/all/published/tags query params filter tag (==,@=) GET api/public/v1/summits/{id}/events/published GET api/public/v1/summits/{id}/events/{event_id}/published OAUTH2 GET /api/v1/summits/{id}/events/all/published/tags Required scopes REALM_URL/summits/read REALM_URL/summits/read/all Change-Id: Iba2005dce6039a7db7408022053aec3df53cd584
This commit is contained in:
parent
17baf70f8c
commit
b81f951093
|
@ -11,7 +11,6 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use App\Http\Utils\BooleanCellFormatter;
|
use App\Http\Utils\BooleanCellFormatter;
|
||||||
use App\Http\Utils\EpochCellFormatter;
|
use App\Http\Utils\EpochCellFormatter;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
@ -31,12 +30,13 @@ use models\summit\ISummitEventRepository;
|
||||||
use models\summit\ISummitRepository;
|
use models\summit\ISummitRepository;
|
||||||
use ModelSerializers\SerializerRegistry;
|
use ModelSerializers\SerializerRegistry;
|
||||||
use services\model\ISummitService;
|
use services\model\ISummitService;
|
||||||
|
use utils\Filter;
|
||||||
|
use utils\FilterElement;
|
||||||
use utils\FilterParser;
|
use utils\FilterParser;
|
||||||
use utils\FilterParserException;
|
use utils\FilterParserException;
|
||||||
use utils\OrderParser;
|
use utils\OrderParser;
|
||||||
use utils\PagingInfo;
|
use utils\PagingInfo;
|
||||||
use utils\PagingResponse;
|
use utils\PagingResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class OAuth2SummitEventsApiController
|
* Class OAuth2SummitEventsApiController
|
||||||
* @package App\Http\Controllers
|
* @package App\Http\Controllers
|
||||||
|
@ -197,6 +197,55 @@ final class OAuth2SummitEventsApiController extends OAuth2ProtectedController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use ParametrizedGetAll;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $summit_id
|
||||||
|
* @return \Illuminate\Http\JsonResponse|mixed
|
||||||
|
*/
|
||||||
|
public function getScheduledEventsTags($summit_id){
|
||||||
|
$summit = SummitFinderStrategyFactory::build($this->getRepository(), $this->getResourceServerContext())->find($summit_id);
|
||||||
|
if (is_null($summit)) return $this->error404();
|
||||||
|
|
||||||
|
return $this->getAll(
|
||||||
|
function(){
|
||||||
|
return [
|
||||||
|
'tag' => ['=@', '=='],
|
||||||
|
];
|
||||||
|
},
|
||||||
|
function(){
|
||||||
|
return [
|
||||||
|
'tag' => 'sometimes|string',
|
||||||
|
];
|
||||||
|
},
|
||||||
|
function()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'tag'
|
||||||
|
];
|
||||||
|
},
|
||||||
|
function($filter) use($summit){
|
||||||
|
if($filter instanceof Filter){
|
||||||
|
$filter->addFilterCondition(FilterElement::makeEqual('summit_id', $summit->getId()));
|
||||||
|
}
|
||||||
|
return $filter;
|
||||||
|
},
|
||||||
|
function(){
|
||||||
|
return SerializerRegistry::SerializerType_Public;
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
function ($page, $per_page, $filter, $order, $applyExtraFilters){
|
||||||
|
return $this->event_repository->getAllPublishedTagsByPage
|
||||||
|
(
|
||||||
|
new PagingInfo($page, $per_page),
|
||||||
|
call_user_func($applyExtraFilters, $filter),
|
||||||
|
$order
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php namespace App\Http\Controllers;
|
||||||
|
/**
|
||||||
|
* Copyright 2020 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\oauth2\IResourceServerContext;
|
||||||
|
use models\utils\IBaseRepository;
|
||||||
|
/**
|
||||||
|
* Trait BaseAPI
|
||||||
|
* @package App\Http\Controllers
|
||||||
|
*/
|
||||||
|
trait BaseAPI
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return IResourceServerContext
|
||||||
|
*/
|
||||||
|
abstract protected function getResourceServerContext():IResourceServerContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return IBaseRepository
|
||||||
|
*/
|
||||||
|
abstract protected function getRepository():IBaseRepository;
|
||||||
|
}
|
|
@ -0,0 +1,302 @@
|
||||||
|
<?php namespace App\Http\Controllers;
|
||||||
|
/**
|
||||||
|
* 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\Facades\Input;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use models\exceptions\EntityNotFoundException;
|
||||||
|
use models\exceptions\ValidationException;
|
||||||
|
use utils\Filter;
|
||||||
|
use utils\FilterParser;
|
||||||
|
use utils\Order;
|
||||||
|
use utils\OrderParser;
|
||||||
|
use utils\PagingInfo;
|
||||||
|
use App\Http\Utils\PagingConstants;
|
||||||
|
use Exception;
|
||||||
|
/**
|
||||||
|
* Trait ParametrizedGetAll
|
||||||
|
* @package App\Http\Controllers
|
||||||
|
*/
|
||||||
|
trait ParametrizedGetAll
|
||||||
|
{
|
||||||
|
use BaseAPI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $page
|
||||||
|
* @param int $per_page
|
||||||
|
* @param Filter $filter
|
||||||
|
* @param Order $order
|
||||||
|
* @param callable $applyExtraFilters
|
||||||
|
* @return \utils\PagingResponse
|
||||||
|
*/
|
||||||
|
protected function defaultQuery(int $page, int $per_page, Filter $filter, Order $order, callable $applyExtraFilters){
|
||||||
|
return $this->getRepository()->getAllByPage
|
||||||
|
(
|
||||||
|
new PagingInfo($page, $per_page),
|
||||||
|
call_user_func($applyExtraFilters, $filter),
|
||||||
|
$order
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param callable $getFilterRules
|
||||||
|
* @param callable $getFilterValidatorRules
|
||||||
|
* @param callable $getOrderRules
|
||||||
|
* @param callable $applyExtraFilters
|
||||||
|
* @param callable $serializerType
|
||||||
|
* @param callable|null $defaultOrderRules
|
||||||
|
* @param callable|null $defaultPageSize
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getAll
|
||||||
|
(
|
||||||
|
callable $getFilterRules,
|
||||||
|
callable $getFilterValidatorRules,
|
||||||
|
callable $getOrderRules,
|
||||||
|
callable $applyExtraFilters,
|
||||||
|
callable $serializerType,
|
||||||
|
callable $defaultOrderRules = null,
|
||||||
|
callable $defaultPageSize = null,
|
||||||
|
callable $queryCallable = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$values = Input::all();
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
|
||||||
|
'page' => 'integer|min:1',
|
||||||
|
'per_page' => sprintf('required_with:page|integer|min:%s|max:%s', PagingConstants::MinPageSize, PagingConstants::MaxPageSize),
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$validation = Validator::make($values, $rules);
|
||||||
|
|
||||||
|
if ($validation->fails()) {
|
||||||
|
$ex = new ValidationException();
|
||||||
|
throw $ex->setMessages($validation->messages()->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
// default values
|
||||||
|
$page = 1;
|
||||||
|
$per_page = is_null($defaultPageSize) ? PagingConstants::DefaultPageSize : call_user_func($defaultPageSize);
|
||||||
|
|
||||||
|
if (Input::has('page')) {
|
||||||
|
$page = intval(Input::get('page'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input::has('per_page')) {
|
||||||
|
$per_page = intval(Input::get('per_page'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter = null;
|
||||||
|
|
||||||
|
if (Input::has('filter')) {
|
||||||
|
$filter = FilterParser::parse(Input::get('filter'), call_user_func($getFilterRules));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_null($filter)) $filter = new Filter();
|
||||||
|
|
||||||
|
$filter_validator_rules = call_user_func($getFilterValidatorRules);
|
||||||
|
if(count($filter_validator_rules)) {
|
||||||
|
$filter->validate($filter_validator_rules);
|
||||||
|
}
|
||||||
|
|
||||||
|
$order = null;
|
||||||
|
|
||||||
|
if (Input::has('order'))
|
||||||
|
{
|
||||||
|
$order = OrderParser::parse(Input::get('order'), call_user_func($getOrderRules));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(!is_null($defaultOrderRules)){
|
||||||
|
$order = call_user_func($defaultOrderRules);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_null($queryCallable))
|
||||||
|
$data = call_user_func($queryCallable,
|
||||||
|
$page,
|
||||||
|
$per_page,
|
||||||
|
$filter,
|
||||||
|
$order,
|
||||||
|
$applyExtraFilters);
|
||||||
|
else
|
||||||
|
$data = $this->defaultQuery
|
||||||
|
(
|
||||||
|
$page,
|
||||||
|
$per_page,
|
||||||
|
$filter,
|
||||||
|
$order,
|
||||||
|
$applyExtraFilters
|
||||||
|
);
|
||||||
|
|
||||||
|
$fields = Request::input('fields', '');
|
||||||
|
$relations = Request::input('relations', '');
|
||||||
|
|
||||||
|
$relations = !empty($relations) ? explode(',', $relations) : [];
|
||||||
|
$fields = !empty($fields) ? explode(',', $fields) : [];
|
||||||
|
|
||||||
|
return $this->ok
|
||||||
|
(
|
||||||
|
$data->toArray
|
||||||
|
(
|
||||||
|
Request::input('expand', ''),
|
||||||
|
$fields,
|
||||||
|
$relations,
|
||||||
|
[],
|
||||||
|
call_user_func($serializerType)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
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(\HTTP401UnauthorizedException $ex3)
|
||||||
|
{
|
||||||
|
Log::warning($ex3);
|
||||||
|
return $this->error401();
|
||||||
|
}
|
||||||
|
catch (Exception $ex) {
|
||||||
|
Log::error($ex);
|
||||||
|
return $this->error500($ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param callable $getFilterRules
|
||||||
|
* @param callable $getFilterValidatorRules
|
||||||
|
* @param callable $getOrderRules
|
||||||
|
* @param callable $applyExtraFilters
|
||||||
|
* @param callable $serializerType
|
||||||
|
* @param callable $getFormatters
|
||||||
|
* @param callable $getColumns
|
||||||
|
* @param $file_prefix
|
||||||
|
* @param array $serializer_params
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getAllCSV
|
||||||
|
(
|
||||||
|
callable $getFilterRules,
|
||||||
|
callable $getFilterValidatorRules,
|
||||||
|
callable $getOrderRules,
|
||||||
|
callable $applyExtraFilters,
|
||||||
|
callable $serializerType,
|
||||||
|
callable $getFormatters,
|
||||||
|
callable $getColumns,
|
||||||
|
$file_prefix,
|
||||||
|
array $serializer_params = []
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$values = Input::all();
|
||||||
|
$rules = [
|
||||||
|
'page' => 'integer|min:1',
|
||||||
|
'per_page' => sprintf('required_with:page|integer|min:%s|max:%s', PagingConstants::MinPageSize, PagingConstants::MaxPageSize),
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$validation = Validator::make($values, $rules);
|
||||||
|
|
||||||
|
if ($validation->fails()) {
|
||||||
|
$ex = new ValidationException();
|
||||||
|
throw $ex->setMessages($validation->messages()->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
// default values
|
||||||
|
$page = 1;
|
||||||
|
$per_page = PHP_INT_MAX;
|
||||||
|
|
||||||
|
if (Input::has('page')) {
|
||||||
|
$page = intval(Input::get('page'));
|
||||||
|
$per_page = intval(Input::get('per_page'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input::has('per_page')) {
|
||||||
|
$per_page = intval(Input::get('per_page'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter = null;
|
||||||
|
|
||||||
|
if (Input::has('filter')) {
|
||||||
|
$filter = FilterParser::parse(Input::get('filter'), call_user_func($getFilterRules));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_null($filter)) $filter = new Filter();
|
||||||
|
|
||||||
|
$filter_validator_rules = call_user_func($getFilterValidatorRules);
|
||||||
|
if(count($filter_validator_rules)) {
|
||||||
|
$filter->validate($filter_validator_rules);
|
||||||
|
}
|
||||||
|
|
||||||
|
$order = null;
|
||||||
|
|
||||||
|
if (Input::has('order'))
|
||||||
|
{
|
||||||
|
$order = OrderParser::parse(Input::get('order'), call_user_func($getOrderRules));
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $this->getRepository()->getAllByPage
|
||||||
|
(
|
||||||
|
new PagingInfo($page, $per_page),
|
||||||
|
call_user_func($applyExtraFilters, $filter),
|
||||||
|
$order
|
||||||
|
);
|
||||||
|
|
||||||
|
$filename = $file_prefix . date('Ymd');
|
||||||
|
$list = $data->toArray
|
||||||
|
(
|
||||||
|
Request::input('expand', ''),
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
$serializer_params,
|
||||||
|
call_user_func($serializerType)
|
||||||
|
);
|
||||||
|
return $this->export
|
||||||
|
(
|
||||||
|
'csv',
|
||||||
|
$filename,
|
||||||
|
$list['data'],
|
||||||
|
call_user_func($getFormatters),
|
||||||
|
call_user_func($getColumns)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (ValidationException $ex1)
|
||||||
|
{
|
||||||
|
Log::warning($ex1);
|
||||||
|
return $this->error412($ex1->getMessages());
|
||||||
|
}
|
||||||
|
catch (EntityNotFoundException $ex2)
|
||||||
|
{
|
||||||
|
Log::warning($ex2);
|
||||||
|
return $this->error404(array('message' => $ex2->getMessage()));
|
||||||
|
}
|
||||||
|
catch(\HTTP401UnauthorizedException $ex3)
|
||||||
|
{
|
||||||
|
Log::warning($ex3);
|
||||||
|
return $this->error401();
|
||||||
|
}
|
||||||
|
catch (Exception $ex) {
|
||||||
|
Log::error($ex);
|
||||||
|
return $this->error500($ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
<?php namespace App\Http\Controllers;
|
<?php namespace App\Http\Controllers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2015 OpenStack Foundation
|
* Copyright 2015 OpenStack Foundation
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -12,10 +11,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use models\oauth2\IResourceServerContext;
|
use models\oauth2\IResourceServerContext;
|
||||||
use models\utils\IBaseRepository;
|
use models\utils\IBaseRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class OAuth2ProtectedController
|
* Class OAuth2ProtectedController
|
||||||
* OAuth2 Protected Base API
|
* OAuth2 Protected Base API
|
||||||
|
@ -42,4 +39,19 @@ abstract class OAuth2ProtectedController extends JsonController
|
||||||
$this->resource_server_context = $resource_server_context;
|
$this->resource_server_context = $resource_server_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return IResourceServerContext
|
||||||
|
*/
|
||||||
|
protected function getResourceServerContext(): IResourceServerContext
|
||||||
|
{
|
||||||
|
return $this->resource_server_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return IBaseRepository
|
||||||
|
*/
|
||||||
|
protected function getRepository(): IBaseRepository
|
||||||
|
{
|
||||||
|
return $this->repository;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -64,7 +64,26 @@ Route::group([
|
||||||
|
|
||||||
Route::group(['prefix' => '{id}'], function () {
|
Route::group(['prefix' => '{id}'], function () {
|
||||||
Route::get('', [ 'middleware' => 'cache:'.Config::get('cache_api_response.get_summit_response_lifetime', 1200), 'uses' => 'OAuth2SummitApiController@getSummit'])->where('id', 'current|[0-9]+');
|
Route::get('', [ 'middleware' => 'cache:'.Config::get('cache_api_response.get_summit_response_lifetime', 1200), 'uses' => 'OAuth2SummitApiController@getSummit'])->where('id', 'current|[0-9]+');
|
||||||
Route::get('published-events', 'OAuth2SummitEventsApiController@getScheduledEvents');
|
|
||||||
|
Route::group(['prefix' => 'events'], function () {
|
||||||
|
Route::group(['prefix' => 'published'], function () {
|
||||||
|
|
||||||
|
Route::get('', 'OAuth2SummitEventsApiController@getScheduledEvents');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::group(array('prefix' => '{event_id}'), function () {
|
||||||
|
Route::group(['prefix' => 'published'], function () {
|
||||||
|
Route::get('', [ 'middleware' => 'cache:'.Config::get('cache_api_response.get_published_event_response_lifetime', 300), 'uses' => 'OAuth2SummitEventsApiController@getScheduledEvent']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::group(['prefix' => 'all'], function () {
|
||||||
|
Route::group(['prefix' => 'published'], function () {
|
||||||
|
Route::get('tags', 'OAuth2SummitEventsApiController@getScheduledEventsTags');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// locations
|
// locations
|
||||||
Route::group(['prefix' => 'locations'], function () {
|
Route::group(['prefix' => 'locations'], function () {
|
||||||
Route::group(['prefix' => '{location_id}'], function () {
|
Route::group(['prefix' => '{location_id}'], function () {
|
||||||
|
|
|
@ -266,6 +266,12 @@ Route::group([
|
||||||
Route::post('/attachment', [ 'middleware' => 'auth.user', 'uses' => 'OAuth2SummitEventsApiController@addEventAttachment']);
|
Route::post('/attachment', [ 'middleware' => 'auth.user', 'uses' => 'OAuth2SummitEventsApiController@addEventAttachment']);
|
||||||
Route::get('/feedback/{attendee_id?}', ['middleware' => 'cache:'.Config::get('cache_api_response.get_event_feedback_response_lifetime', 300), 'uses' => 'OAuth2SummitEventsApiController@getEventFeedback'] )->where('attendee_id', 'me|[0-9]+');
|
Route::get('/feedback/{attendee_id?}', ['middleware' => 'cache:'.Config::get('cache_api_response.get_event_feedback_response_lifetime', 300), 'uses' => 'OAuth2SummitEventsApiController@getEventFeedback'] )->where('attendee_id', 'me|[0-9]+');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::group(['prefix' => 'all'], function () {
|
||||||
|
Route::group(['prefix' => 'published'], function () {
|
||||||
|
Route::get('tags', 'OAuth2SummitEventsApiController@getScheduledEventsTags');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// presentations
|
// presentations
|
||||||
|
|
|
@ -11,10 +11,9 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use models\utils\SilverstripeBaseModel;
|
use models\utils\SilverstripeBaseModel;
|
||||||
use Doctrine\ORM\Mapping AS ORM;
|
use Doctrine\ORM\Mapping AS ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="Tag")
|
* @ORM\Table(name="Tag")
|
||||||
|
@ -31,6 +30,11 @@ class Tag extends SilverstripeBaseModel
|
||||||
*/
|
*/
|
||||||
private $tag;
|
private $tag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToMany(targetEntity="models\summit\SummitEvent", mappedBy="tags")
|
||||||
|
*/
|
||||||
|
private $events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -55,6 +59,11 @@ class Tag extends SilverstripeBaseModel
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->tag = $tag;
|
$this->tag = $tag;
|
||||||
|
$this->events = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEvents(){
|
||||||
|
return $this->events;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -38,6 +38,14 @@ interface ISummitEventRepository extends IBaseRepository
|
||||||
*/
|
*/
|
||||||
public function getAllByPage(PagingInfo $paging_info, Filter $filter = null, Order $order = null);
|
public function getAllByPage(PagingInfo $paging_info, Filter $filter = null, Order $order = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param PagingInfo $paging_info
|
||||||
|
* @param Filter|null $filter
|
||||||
|
* @param Order|null $order
|
||||||
|
* @return PagingResponse
|
||||||
|
*/
|
||||||
|
public function getAllPublishedTagsByPage(PagingInfo $paging_info, Filter $filter = null, Order $order = null):PagingResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PagingInfo $paging_info
|
* @param PagingInfo $paging_info
|
||||||
* @param Filter|null $filter
|
* @param Filter|null $filter
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
**/
|
**/
|
||||||
use App\Models\Foundation\Main\IGroup;
|
use App\Models\Foundation\Main\IGroup;
|
||||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||||
|
use models\main\Tag;
|
||||||
use models\summit\ISummitEventRepository;
|
use models\summit\ISummitEventRepository;
|
||||||
use models\summit\Presentation;
|
use models\summit\Presentation;
|
||||||
use models\summit\Summit;
|
use models\summit\Summit;
|
||||||
|
@ -356,4 +357,60 @@ final class DoctrineSummitEventRepository
|
||||||
|
|
||||||
return $query->getQuery()->getResult();
|
return $query->getQuery()->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param PagingInfo $paging_info
|
||||||
|
* @param Filter|null $filter
|
||||||
|
* @param Order|null $order
|
||||||
|
* @return PagingResponse
|
||||||
|
*/
|
||||||
|
public function getAllPublishedTagsByPage(PagingInfo $paging_info, Filter $filter = null, Order $order = null): PagingResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
$query = $this->getEntityManager()->createQueryBuilder()
|
||||||
|
->select("distinct t")
|
||||||
|
->from(Tag::class, "t")
|
||||||
|
->join("t.events", 'e')
|
||||||
|
->leftJoin(Presentation::class, 'p', 'WITH', 'e.id = p.id');
|
||||||
|
|
||||||
|
if(!is_null($filter)){
|
||||||
|
$filter->apply2Query($query, [
|
||||||
|
'tag' => 't.tag:json_string',
|
||||||
|
'summit_id'=> new DoctrineJoinFilterMapping
|
||||||
|
(
|
||||||
|
'e.summit',
|
||||||
|
's',
|
||||||
|
"s.id :operator :value"
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($order)) {
|
||||||
|
$order->apply2Query($query, [
|
||||||
|
'tag' => 't.tag',
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$query = $query->addOrderBy("t.tag", 'ASC');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $query
|
||||||
|
->setFirstResult($paging_info->getOffset())
|
||||||
|
->setMaxResults($paging_info->getPerPage());
|
||||||
|
|
||||||
|
$paginator = new Paginator($query, $fetchJoinCollection = true);
|
||||||
|
$total = $paginator->count();
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach($paginator as $entity)
|
||||||
|
$data[]= $entity;
|
||||||
|
|
||||||
|
return new PagingResponse
|
||||||
|
(
|
||||||
|
$total,
|
||||||
|
$paging_info->getPerPage(),
|
||||||
|
$paging_info->getCurrentPage(),
|
||||||
|
$paging_info->getLastPage($total),
|
||||||
|
$data
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2013,6 +2013,15 @@ class ApiEndpointsSeeder extends Seeder
|
||||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'get-published-events-tags',
|
||||||
|
'route' => '/api/v1/summits/{id}/events/all/published/tags',
|
||||||
|
'http_method' => 'GET',
|
||||||
|
'scopes' => [
|
||||||
|
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||||
|
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||||
|
],
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'get-schedule-empty-spots',
|
'name' => 'get-schedule-empty-spots',
|
||||||
'route' => '/api/v1/summits/{id}/events/published/empty-spots',
|
'route' => '/api/v1/summits/{id}/events/published/empty-spots',
|
||||||
|
|
|
@ -646,6 +646,36 @@ final class OAuth2SummitEventsApiTest extends ProtectedApiTest
|
||||||
$this->assertTrue(!is_null($events));
|
$this->assertTrue(!is_null($events));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetScheduledEventsTags($summit_id = 27)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
|
||||||
|
'id' => $summit_id,
|
||||||
|
];
|
||||||
|
|
||||||
|
$headers = [
|
||||||
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||||
|
"CONTENT_TYPE" => "application/json"
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->action
|
||||||
|
(
|
||||||
|
"GET",
|
||||||
|
"OAuth2SummitEventsApiController@getScheduledEventsTags",
|
||||||
|
$params,
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
$headers
|
||||||
|
);
|
||||||
|
|
||||||
|
$content = $response->getContent();
|
||||||
|
$this->assertResponseStatus(200);
|
||||||
|
|
||||||
|
$tags = json_decode($content);
|
||||||
|
$this->assertTrue(!is_null($tags));
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetORSpeakers($summit_id=24)
|
public function testGetORSpeakers($summit_id=24)
|
||||||
{
|
{
|
||||||
$params = array
|
$params = array
|
||||||
|
|
Loading…
Reference in New Issue