-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8ecf6e
commit 2b4b857
Showing
3 changed files
with
31 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
namespace craft\models; | ||
|
||
use Craft; | ||
use craft\base\Chippable; | ||
use craft\base\Model; | ||
use craft\helpers\App; | ||
use craft\i18n\Locale; | ||
|
@@ -29,8 +30,14 @@ | |
* @author Pixel & Tonic, Inc. <[email protected]> | ||
* @since 3.0.0 | ||
*/ | ||
class Site extends Model | ||
class Site extends Model implements Chippable | ||
{ | ||
public static function get(int|string $id): ?static | ||
{ | ||
/** @phpstan-ignore-next-line */ | ||
return Craft::$app->getSites()->getSiteById($id); | ||
} | ||
|
||
/** | ||
* @var int|null ID | ||
*/ | ||
|
@@ -104,6 +111,22 @@ class Site extends Model | |
*/ | ||
private ?string $_language = null; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getId(): string|int|null | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getUiLabel(): string | ||
{ | ||
return Craft::t('site', $this->getName()); | ||
} | ||
|
||
/** | ||
* Returns the site’s name. | ||
* | ||
|
@@ -264,7 +287,7 @@ public function attributes(): array | |
*/ | ||
public function __toString(): string | ||
{ | ||
return Craft::t('site', $this->getName()) ?: static::class; | ||
return $this->getUiLabel() ?: static::class; | ||
} | ||
|
||
/** | ||
|