-
Notifications
You must be signed in to change notification settings - Fork 40
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. Add unit and functional tests for AccessRegistry and Hook. Introduce several unit tests for AccessRegistry, AllowedGlossarySyncAccess, and AllowedTranslateAccess. Also, add functional tests for ButtonBarHook and TranslateHook to ensure correct behavior of glossary synchronization button and related access checks. Add documentation for backend group access configuration Included a new Index.rst file under Administration/Access to explain backend group permissions. Added an image to illustrate backend access rights and updated main documentation index to reference the new page.
- Loading branch information
Showing
30 changed files
with
765 additions
and
187 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.