Commit fc38bee0 authored by catch's avatar catch

Issue #1987856 by vijaycs85, mparker17, sidharthap: Convert system_timezone()...

Issue #1987856 by vijaycs85, mparker17, sidharthap: Convert system_timezone() to a new style controller.
parent ea77909c
<?php
/**
* @file
* Contains \Drupal\system\TimezoneController.
*/
namespace Drupal\system\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
/**
* Provides a callback for finding out a timezone name.
*/
class TimezoneController {
/**
* Retrieve a JSON object containing a time zone name given a timezone
* abbreviation.
*
* @param string $abbreviation
* Time zone abbreviation.
* @param int $offset
* Offset from GMT in seconds. Defaults to -1 which means that first found
* time zone corresponding to abbr is returned. Otherwise exact offset is
* searched and only if not found then the first time zone with any offset
* is returned.
* @param null|bool $is_daylight_saving_time
* Daylight saving time indicator. If abbr does not exist then the time
* zone is searched solely by offset and isdst.
*
* @return JsonResponse
* The timezone name in JsonResponse object.
*/
public function getTimezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) {
// An abbreviation of "0" passed in the callback arguments should be
// interpreted as the empty string.
$abbreviation = $abbreviation ? $abbreviation : '';
$timezone = timezone_name_from_abbr($abbreviation, intval($offset), $is_daylight_saving_time);
return new JsonResponse($timezone);
}
}
......@@ -637,13 +637,6 @@ function system_menu() {
'file path' => 'core/includes',
'file' => 'form.inc',
);
$items['system/timezone'] = array(
'title' => 'Time zone',
'page callback' => 'system_timezone',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'system.admin.inc',
);
$items['admin'] = array(
'title' => 'Administration',
'access arguments' => array('access administration pages'),
......@@ -3463,17 +3456,6 @@ function system_time_zones($blank = NULL) {
return $zones;
}
/**
* Menu callback; Retrieve a JSON object containing a suggested time zone name.
*/
function system_timezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) {
// An abbreviation of "0" passed in the callback arguments should be
// interpreted as the empty string.
$abbreviation = $abbreviation ? $abbreviation : '';
$timezone = timezone_name_from_abbr($abbreviation, intval($offset), $is_daylight_saving_time);
return new JsonResponse($timezone);
}
/**
* Returns HTML for the Powered by Drupal text.
*
......
......@@ -157,3 +157,10 @@ system_theme_settings_global:
_form: '\Drupal\system\Form\ThemeSettingsForm'
requirements:
_permission: 'administer themes'
system_timezone:
pattern: '/system/timezone'
defaults:
_controller: '\Drupal\system\Controller\TimezoneController::getTimezone'
requirements:
_access: 'TRUE'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment