Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
feat(composer): Add nesbot/carbon to deal with Date and Time
Browse files Browse the repository at this point in the history
1. Add `nesbot/carbon` to deal with Date and Time
2. Make I18n::getUserLang() public
  • Loading branch information
Rhilip committed Feb 26, 2020
1 parent 85a9587 commit 9e37c41
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 59 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- **Requests:** Make Response Component extends from `Symfony\Component\HttpFoundation\Response` (dd001d2)
- **Requests:** Make Request Component extends from `Symfony\Component\HttpFoundation\Request` (9cd715b)
- **Torrent:** Per-add torrent edit (f06b342)
- **Torrents:** Allow search in user's favour (or you can say bookmark) (c0aa627)
- **i18n:** Use symfony/translation and JSON format for locale (02cc251)
- **layout:** Add anti-robots html meta tag (9c21e73)

Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"firebase/php-jwt": "^5.0",
"league/plates": "^3.3",
"mjohnson/decoda": "^6.12",
"nesbot/carbon": "^2.30",
"phpmailer/phpmailer": "^6.0",
"psr/log": "^1.1",
"rhilip/bencode": "^1.0",
Expand Down Expand Up @@ -63,3 +64,6 @@
},
"prefer-stable": true
}
,
"prefer-stable": true
}
140 changes: 105 additions & 35 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions framework/Component/I18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@

class I18n extends Component
{
public $loader = [];
public $resources = [];
public array $loader = [];
public array $resources = [];

public $cacheDir = '';
public string $cacheDir = '';

/**
* Allowed language
* This is the set of language which is used to limit user languages. No-exist language will not accept.
*
* @var array
*/
public $allowedLangSet = ['en', 'zh-CN'];
public array $allowedLangSet = ['en', 'zh-CN'];

/**
* Fallback language
Expand All @@ -33,23 +33,23 @@ class I18n extends Component
*
* @var string
*/
public $fallbackLang = 'en';
public string $fallbackLang = 'en';

/**
* Forced language
* If you want to force a specific language define it here.
*
* @var string
*/
public $forcedLang = null;
public ?string $forcedLang = null;

/*
* The following properties are only available after calling init().
*/
protected $_user_lang = null;
protected ?string $_user_lang = null;

/** @var Translator */
protected $_translator;
protected ?Translator $_translator;

public function onRequestBefore()
{
Expand Down Expand Up @@ -85,7 +85,7 @@ public function onInitialize()
*
* @return string the user languages sorted by priority.
*/
private function getUserLang()
public function getUserLang()
{
// Return Cache value
if (!is_null($this->_user_lang)) {
Expand Down
5 changes: 1 addition & 4 deletions framework/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Request extends HttpFoundationRequest implements Base\StaticInstanceInterf
{
use Base\StaticInstanceTrait, Base\ComponentTrait;

protected $_swoole_request;
protected \Swoole\Http\Request $_swoole_request;
protected $_route = [];

/**
Expand Down Expand Up @@ -77,9 +77,6 @@ public function route($name = null, $default = null)
return is_null($name) ? $this->_route : ($this->_route[$name] ?? $default);
}

/**
* @return mixed
*/
public function getSwooleRequest(): \Swoole\Http\Request
{
return $this->_swoole_request;
Expand Down
Loading

0 comments on commit 9e37c41

Please sign in to comment.