-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Introduce translation access features for backend user groups
Add new Items custom_options to the be_groups table, access to deepltranslate translate option.
- Loading branch information
Showing
19 changed files
with
420 additions
and
186 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace WebVision\WvDeepltranslate\Access; | ||
|
||
interface AccessItemInterface | ||
{ | ||
/** | ||
* Unique access identifier | ||
* | ||
* @return string | ||
*/ | ||
public function getIdentifier(): string; | ||
|
||
/** | ||
* The title of the access | ||
* | ||
* @return string | ||
*/ | ||
public function getTitle(): string; | ||
|
||
/** | ||
* A short description about the access | ||
* | ||
* @return string | ||
*/ | ||
public function getDescription(): string; | ||
|
||
/** | ||
* The icon identifier for this access | ||
* | ||
* @return string | ||
*/ | ||
public function getIconIdentifier(): string; | ||
} |
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,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace WebVision\WvDeepltranslate\Access; | ||
|
||
use TYPO3\CMS\Core\SingletonInterface; | ||
|
||
final class AccessRegistry implements SingletonInterface | ||
{ | ||
/** | ||
* @var AccessItemInterface[] | ||
*/ | ||
private static $access = []; | ||
|
||
public function addAccess(AccessItemInterface $accessItem): void | ||
{ | ||
self::$access[] = $accessItem; | ||
} | ||
|
||
/** | ||
* @return AccessItemInterface[] | ||
*/ | ||
public function getAllAccess(): array | ||
{ | ||
return self::$access; | ||
} | ||
|
||
public function getAccess(string $identifier): ?AccessItemInterface | ||
{ | ||
foreach (self::$access as $accessItem) { | ||
if ($accessItem->getIdentifier() === $identifier) { | ||
return $accessItem; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public function hasAccess(string $identifier): bool | ||
{ | ||
$object = $this->getAccess($identifier); | ||
return $object !== null; | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace WebVision\WvDeepltranslate\Access; | ||
|
||
class AllowedGlossarySyncAccess implements AccessItemInterface | ||
{ | ||
public const ALLOWED_GLOSSARY_SYNC = 'deepltranslate:allowedGlossarySync'; | ||
|
||
public function getIdentifier(): string | ||
{ | ||
return 'allowedGlossarySync'; | ||
} | ||
|
||
public function getTitle(): string | ||
{ | ||
return 'LLL:EXT:wv_deepltranslate/Resources/Private/Language/locallang.xlf:be_groups.deepltranslate_access.items.allowedGlossarySync.title'; | ||
} | ||
|
||
public function getDescription(): string | ||
{ | ||
return 'LLL:EXT:wv_deepltranslate/Resources/Private/Language/locallang.xlf:be_groups.deepltranslate_access.items.allowedGlossarySync.description'; | ||
} | ||
|
||
public function getIconIdentifier(): string | ||
{ | ||
return 'deepl-logo'; | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace WebVision\WvDeepltranslate\Access; | ||
|
||
final class AllowedTranslateAccess implements AccessItemInterface | ||
{ | ||
public const ALLOWED_TRANSLATE_OPTION_VALUE = 'deepltranslate:translateAllowed'; | ||
|
||
public function getIdentifier(): string | ||
{ | ||
return 'translateAllowed'; | ||
} | ||
|
||
public function getTitle(): string | ||
{ | ||
return 'LLL:EXT:wv_deepltranslate/Resources/Private/Language/locallang.xlf:be_groups.deepltranslate_access.items.translateAllowed.title'; | ||
} | ||
|
||
public function getDescription(): string | ||
{ | ||
return 'LLL:EXT:wv_deepltranslate/Resources/Private/Language/locallang.xlf:be_groups.deepltranslate_access.items.translateAllowed.description'; | ||
} | ||
|
||
public function getIconIdentifier(): string | ||
{ | ||
return 'deepl-logo'; | ||
} | ||
} |
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
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
Oops, something went wrong.