-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breaking changes: Languages are used for Domain Models and must be ma…
…pped in TypoScript - A mapping for each used language must be defined in `plugin.tx_rest.settings.languages` - System language is respected for Extbase Domain Models
- Loading branch information
Showing
5 changed files
with
162 additions
and
51 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
Classes/Bootstrap/Language/Exception/InvalidLanguageException.php
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Cundd\Rest\Bootstrap\Language\Exception; | ||
|
||
use RuntimeException; | ||
|
||
class InvalidLanguageException extends RuntimeException | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
Classes/Bootstrap/Language/Exception/MissingLanguageCodeException.php
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Cundd\Rest\Bootstrap\Language\Exception; | ||
|
||
class MissingLanguageCodeException extends InvalidLanguageException | ||
{ | ||
} |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Cundd\Rest\Bootstrap\Language; | ||
|
||
use Cundd\Rest\Bootstrap\Language\Exception\MissingLanguageCodeException; | ||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage; | ||
|
||
class LanguageInformation | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
private $uid; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $code; | ||
|
||
/** | ||
* LanguageInformation constructor. | ||
* | ||
* @param int $uid | ||
* @param string $code | ||
*/ | ||
public function __construct(int $uid, ?string $code) | ||
{ | ||
$this->uid = $uid; | ||
if (!$code) { | ||
throw new MissingLanguageCodeException('Two Letter ISO Code must be given'); | ||
} | ||
$this->code = $code; | ||
} | ||
|
||
public static function fromSiteLanguage(SiteLanguage $siteLanguage): self | ||
{ | ||
return new static($siteLanguage->getLanguageId(), $siteLanguage->getTwoLetterIsoCode()); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getUid(): int | ||
{ | ||
return $this->uid; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCode(): string | ||
{ | ||
return $this->code; | ||
} | ||
} |
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