diff options
author | Joas Schilling <coding@schilljs.com> | 2016-07-27 10:02:53 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-07-27 14:56:21 +0200 |
commit | 62219c7b2d36bc304a8f537cf88845edf24c8d91 (patch) | |
tree | efe3df83ef24bd9ac9eb7861b9c1948530bac080 /apps/workflowengine/lib | |
parent | 10726dd00df37be77c3088302e16e64b09a6d25f (diff) | |
download | nextcloud-server-62219c7b2d36bc304a8f537cf88845edf24c8d91.tar.gz nextcloud-server-62219c7b2d36bc304a8f537cf88845edf24c8d91.zip |
Add L10N support
Diffstat (limited to 'apps/workflowengine/lib')
-rw-r--r-- | apps/workflowengine/lib/Check/UserGroupMembership.php | 12 | ||||
-rw-r--r-- | apps/workflowengine/lib/Manager.php | 14 |
2 files changed, 19 insertions, 7 deletions
diff --git a/apps/workflowengine/lib/Check/UserGroupMembership.php b/apps/workflowengine/lib/Check/UserGroupMembership.php index f437dbfc2d1..6390c57fbea 100644 --- a/apps/workflowengine/lib/Check/UserGroupMembership.php +++ b/apps/workflowengine/lib/Check/UserGroupMembership.php @@ -24,6 +24,7 @@ namespace OCA\WorkflowEngine\Check; use OCP\Files\Storage\IStorage; use OCP\IGroupManager; +use OCP\IL10N; use OCP\IUser; use OCP\IUserSession; use OCP\WorkflowEngine\ICheck; @@ -42,13 +43,18 @@ class UserGroupMembership implements ICheck { /** @var IGroupManager */ protected $groupManager; + /** @var IL10N */ + protected $l; + /** * @param IUserSession $userSession * @param IGroupManager $groupManager + * @param IL10N $l */ - public function __construct(IUserSession $userSession, IGroupManager $groupManager) { + public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) { $this->userSession = $userSession; $this->groupManager = $groupManager; + $this->l = $l; } /** @@ -83,11 +89,11 @@ class UserGroupMembership implements ICheck { */ public function validateCheck($operator, $value) { if (!in_array($operator, ['is', '!is'])) { - throw new \UnexpectedValueException('Invalid operator', 1); + throw new \UnexpectedValueException($this->l->t('Operator %s is invalid', $operator), 1); } if (!$this->groupManager->groupExists($value)) { - throw new \UnexpectedValueException('Group does not exist', 2); + throw new \UnexpectedValueException($this->l->t('Group %s does not exist', $value), 2); } } diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php index f2a04dfb0fa..b72836a919c 100644 --- a/apps/workflowengine/lib/Manager.php +++ b/apps/workflowengine/lib/Manager.php @@ -26,6 +26,7 @@ use OCP\AppFramework\QueryException; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Storage\IStorage; use OCP\IDBConnection; +use OCP\IL10N; use OCP\IServerContainer; use OCP\WorkflowEngine\ICheck; use OCP\WorkflowEngine\IManager; @@ -50,13 +51,18 @@ class Manager implements IManager { /** @var IServerContainer|\OC\Server */ protected $container; + /** @var IL10N */ + protected $l; + /** * @param IDBConnection $connection * @param IServerContainer $container + * @param IL10N $l */ - public function __construct(IDBConnection $connection, IServerContainer $container) { + public function __construct(IDBConnection $connection, IServerContainer $container, IL10N $l) { $this->connection = $connection; $this->container = $container; + $this->l = $l; } /** @@ -111,7 +117,7 @@ class Manager implements IManager { return $checkInstance->executeCheck($check['operator'], $check['value']); } else { // Check is invalid - throw new \RuntimeException('Check ' . htmlspecialchars($check['class']) . ' is invalid or does not exist'); + throw new \UnexpectedValueException($this->l->t('Check %s is invalid or does not exist', $check['class'])); } } @@ -158,7 +164,7 @@ class Manager implements IManager { return $row; } - throw new \UnexpectedValueException('Operation does not exist'); + throw new \UnexpectedValueException($this->l->t('Operation #%s does not exist', $id)); } /** @@ -262,7 +268,7 @@ class Manager implements IManager { if (!empty($checkIds)) { $missingCheck = array_pop($checkIds); - throw new \RuntimeException('Check #' . htmlspecialchars($missingCheck) . ' is invalid or does not exist'); + throw new \UnexpectedValueException($this->l->t('Check #%s does not exist', $missingCheck)); } return $checks; |