Remove remnants of Timezonelist library

This commit is contained in:
Nabeel Shahzad 2019-09-13 17:54:46 -04:00
parent 4ac781a20d
commit 0c89d36a16
7 changed files with 36 additions and 57 deletions

View File

@ -12,9 +12,9 @@ use App\Repositories\AirportRepository;
use App\Repositories\Criteria\WhereCriteria; use App\Repositories\Criteria\WhereCriteria;
use App\Services\ExportService; use App\Services\ExportService;
use App\Services\ImportService; use App\Services\ImportService;
use App\Support\Timezonelist;
use Flash; use Flash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Jackiedo\Timezonelist\Facades\Timezonelist;
use Log; use Log;
use Response; use Response;
use Storage; use Storage;

View File

@ -14,11 +14,11 @@ use App\Repositories\AirportRepository;
use App\Repositories\PirepRepository; use App\Repositories\PirepRepository;
use App\Repositories\UserRepository; use App\Repositories\UserRepository;
use App\Services\UserService; use App\Services\UserService;
use App\Support\Timezonelist;
use DB; use DB;
use Flash; use Flash;
use Hash; use Hash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Jackiedo\Timezonelist\Facades\Timezonelist;
use Log; use Log;
use Prettus\Repository\Exceptions\RepositoryException; use Prettus\Repository\Exceptions\RepositoryException;
use Response; use Response;

View File

@ -10,12 +10,12 @@ use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository; use App\Repositories\AirportRepository;
use App\Services\UserService; use App\Services\UserService;
use App\Support\Countries; use App\Support\Countries;
use App\Support\Timezonelist;
use Illuminate\Contracts\Validation\Validator; use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Jackiedo\Timezonelist\Facades\Timezonelist;
/** /**
* Class RegisterController * Class RegisterController
@ -56,6 +56,8 @@ class RegisterController extends Controller
} }
/** /**
* @throws \Exception
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/ */
public function showRegistrationForm() public function showRegistrationForm()

View File

@ -9,15 +9,15 @@ use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository; use App\Repositories\AirportRepository;
use App\Repositories\UserRepository; use App\Repositories\UserRepository;
use App\Support\Countries; use App\Support\Countries;
use Flash; use App\Support\Timezonelist;
use Hash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use Intervention\Image\Facades\Image; use Intervention\Image\Facades\Image;
use Jackiedo\Timezonelist\Facades\Timezonelist; use Laracasts\Flash\Flash;
use Log;
use Validator;
/** /**
* Class ProfileController * Class ProfileController
@ -86,9 +86,10 @@ class ProfileController extends Controller
/** /**
* Show the edit for form the user's profile * Show the edit for form the user's profile
*
* @param Request $request * @param Request $request
* *
* @throws \Exception
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/ */
public function edit(Request $request) public function edit(Request $request)

View File

@ -1,30 +0,0 @@
<?php
namespace App\Providers;
use App\Support\Timezonelist;
use Illuminate\Support\ServiceProvider;
class TimezonelistProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
}
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->singleton('timezonelist', function ($app) {
return new Timezonelist();
});
}
}

View File

@ -22,12 +22,14 @@
namespace App\Support; namespace App\Support;
use DateTimeZone; use DateTimeZone;
use Illuminate\Support\Facades\Log;
/** /**
* This library is from: * This library is from:
* https://github.com/JackieDo/Timezone-List * https://github.com/JackieDo/Timezone-List
* *
* With some changes to suite the formatting, etc that we need * With some changes to suite the formatting, etc that we need.
* Also changed it to provide all static methods instead of through a facade
*/ */
class Timezonelist class Timezonelist
{ {
@ -40,7 +42,7 @@ class Timezonelist
* *
* @var array * @var array
*/ */
protected $popularTimezones = [ protected static $popularTimezones = [
'GMT' => 'GMT timezone', 'GMT' => 'GMT timezone',
'UTC' => 'UTC timezone', 'UTC' => 'UTC timezone',
]; ];
@ -49,7 +51,7 @@ class Timezonelist
* *
* @var array * @var array
*/ */
protected $continents = [ protected static $continents = [
'Africa' => DateTimeZone::AFRICA, 'Africa' => DateTimeZone::AFRICA,
'America' => DateTimeZone::AMERICA, 'America' => DateTimeZone::AMERICA,
'Antarctica' => DateTimeZone::ANTARCTICA, 'Antarctica' => DateTimeZone::ANTARCTICA,
@ -69,14 +71,17 @@ class Timezonelist
* @param string $continent * @param string $continent
* @param bool $htmlencode * @param bool $htmlencode
* *
* @throws \Exception
* @throws \Exception
*
* @return string * @return string
*/ */
protected function formatTimezone($timezone, $continent, $htmlencode = true) public static function formatTimezone($timezone, $continent, $htmlencode = true)
{ {
$time = new \DateTimeImmutable(null, new DateTimeZone($timezone)); try {
$time = new \DateTimeImmutable(null, new DateTimeZone($timezone));
} catch (\Exception $e) {
Log::error($e->getMessage());
return '';
}
$offset = $time->format('P'); $offset = $time->format('P');
if ($htmlencode) { if ($htmlencode) {
$offset = str_replace(['-', '+'], [' &minus; ', ' &plus; '], $offset); $offset = str_replace(['-', '+'], [' &minus; ', ' &plus; '], $offset);
@ -95,9 +100,11 @@ class Timezonelist
* @param mixed $attr * @param mixed $attr
* @param bool $htmlencode * @param bool $htmlencode
* *
* @throws \Exception
*
* @return string * @return string
*/ */
public function create($name, $selected = '', $attr = '', $htmlencode = true) public static function create($name, $selected = '', $attr = '', $htmlencode = true)
{ {
// Attributes for select element // Attributes for select element
$attrSet = ''; $attrSet = '';
@ -114,13 +121,13 @@ class Timezonelist
$listbox = '<select name="'.$name.'"'.$attrSet.'>'; $listbox = '<select name="'.$name.'"'.$attrSet.'>';
// Add popular timezones // Add popular timezones
$listbox .= '<optgroup label="General">'; $listbox .= '<optgroup label="General">';
foreach ($this->popularTimezones as $key => $value) { foreach (self::$popularTimezones as $key => $value) {
$selected_attr = ($selected === $key) ? ' selected="selected"' : ''; $selected_attr = ($selected === $key) ? ' selected="selected"' : '';
$listbox .= '<option value="'.$key.'"'.$selected_attr.'>'.$value.'</option>'; $listbox .= '<option value="'.$key.'" '.$selected_attr.'>'.$value.'</option>';
} }
$listbox .= '</optgroup>'; $listbox .= '</optgroup>';
// Add all timezone of continents // Add all timezone of continents
foreach ($this->continents as $continent => $mask) { foreach (self::$continents as $continent => $mask) {
$timezones = DateTimeZone::listIdentifiers($mask); $timezones = DateTimeZone::listIdentifiers($mask);
// start optgroup tag // start optgroup tag
$listbox .= '<optgroup label="'.$continent.'">'; $listbox .= '<optgroup label="'.$continent.'">';
@ -128,7 +135,7 @@ class Timezonelist
foreach ($timezones as $timezone) { foreach ($timezones as $timezone) {
$selected_attr = ($selected === $timezone) ? ' selected="selected"' : ''; $selected_attr = ($selected === $timezone) ? ' selected="selected"' : '';
$listbox .= '<option value="'.$timezone.'"'.$selected_attr.'>'; $listbox .= '<option value="'.$timezone.'"'.$selected_attr.'>';
$listbox .= $this->formatTimezone($timezone, $continent, $htmlencode); $listbox .= static::formatTimezone($timezone, $continent, $htmlencode);
$listbox .= '</option>'; $listbox .= '</option>';
} }
// end optgroup tag // end optgroup tag
@ -146,18 +153,18 @@ class Timezonelist
* *
* @return mixed * @return mixed
*/ */
public function toArray($htmlencode = false) public static function toArray($htmlencode = false)
{ {
$list = []; $list = [];
// Add popular timezones to list // Add popular timezones to list
foreach ($this->popularTimezones as $key => $value) { foreach (self::$popularTimezones as $key => $value) {
$list['General'][$key] = $value; $list['General'][$key] = $value;
} }
// Add all timezone of continents to list // Add all timezone of continents to list
foreach ($this->continents as $continent => $mask) { foreach (self::$continents as $continent => $mask) {
$timezones = DateTimeZone::listIdentifiers($mask); $timezones = DateTimeZone::listIdentifiers($mask);
foreach ($timezones as $timezone) { foreach ($timezones as $timezone) {
$list[$continent][$timezone] = $this->formatTimezone($timezone, $continent, $htmlencode); $list[$continent][$timezone] = self::formatTimezone($timezone, $continent, $htmlencode);
} }
} }
return $list; return $list;

View File

@ -82,7 +82,6 @@ return [
App\Providers\AuthServiceProvider::class, App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class, App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class, App\Providers\RouteServiceProvider::class,
App\Providers\TimezonelistProvider::class,
App\Providers\MeasurementsProvider::class, App\Providers\MeasurementsProvider::class,
App\Providers\BindServiceProviders::class, App\Providers\BindServiceProviders::class,
], ],