Added time zone endpoint
Change-Id: I3d1f95e4b25952f1618337e5fb2f523863d2de80 Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
fb1bf0178d
commit
01dd8f3c15
57
app/Http/Controllers/Apis/TimezonesApiController.php
Normal file
57
app/Http/Controllers/Apis/TimezonesApiController.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
/**
|
||||
* Copyright 2021 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 models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
use utils\PagingResponse;
|
||||
/**
|
||||
* Class TimezonesApiController
|
||||
* @package App\Http\Controllers
|
||||
*/
|
||||
final class TimezonesApiController extends JsonController
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAll(){
|
||||
try {
|
||||
$timezones = \DateTimeZone::listIdentifiers();
|
||||
$response = new PagingResponse
|
||||
(
|
||||
count($timezones),
|
||||
count($timezones),
|
||||
1,
|
||||
1,
|
||||
$timezones
|
||||
);
|
||||
|
||||
return $this->ok($response->toArray($expand = Input::get('expand','')));
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -223,6 +223,12 @@ Route::group([
|
||||
Route::get('', 'LanguagesApiController@getAll');
|
||||
});
|
||||
|
||||
|
||||
// timezones
|
||||
Route::group(array('prefix' => 'timezones'), function () {
|
||||
Route::get('', 'TimezonesApiController@getAll');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Route::group([
|
||||
|
Loading…
Reference in New Issue
Block a user