summaryrefslogtreecommitdiffstats
path: root/apps/workflowengine/lib/Check/RequestTime.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-08-01 17:56:33 +0200
committerJoas Schilling <coding@schilljs.com>2016-08-01 17:56:33 +0200
commit6aa5d674d63db69367c97e7241e7d1575ef82690 (patch)
tree74600c656ba8034fd20847cf9853d748df30d189 /apps/workflowengine/lib/Check/RequestTime.php
parentea4c6bd28568bce811c275d46478f44455cf237d (diff)
downloadnextcloud-server-6aa5d674d63db69367c97e7241e7d1575ef82690.tar.gz
nextcloud-server-6aa5d674d63db69367c97e7241e7d1575ef82690.zip
Translate the errors
Diffstat (limited to 'apps/workflowengine/lib/Check/RequestTime.php')
-rw-r--r--apps/workflowengine/lib/Check/RequestTime.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/apps/workflowengine/lib/Check/RequestTime.php b/apps/workflowengine/lib/Check/RequestTime.php
index a114819d450..2aa79e77673 100644
--- a/apps/workflowengine/lib/Check/RequestTime.php
+++ b/apps/workflowengine/lib/Check/RequestTime.php
@@ -24,6 +24,7 @@ namespace OCA\WorkflowEngine\Check;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\Storage\IStorage;
+use OCP\IL10N;
use OCP\WorkflowEngine\ICheck;
class RequestTime implements ICheck {
@@ -34,13 +35,17 @@ class RequestTime implements ICheck {
/** @var bool[] */
protected $cachedResults;
+ /** @var IL10N */
+ protected $l;
+
/** @var ITimeFactory */
protected $timeFactory;
/**
* @param ITimeFactory $timeFactory
*/
- public function __construct(ITimeFactory $timeFactory) {
+ public function __construct(IL10N $l, ITimeFactory $timeFactory) {
+ $this->l = $l;
$this->timeFactory = $timeFactory;
}
@@ -101,24 +106,24 @@ class RequestTime implements ICheck {
*/
public function validateCheck($operator, $value) {
if (!in_array($operator, ['in', '!in'])) {
- throw new \UnexpectedValueException('Invalid operator', 1);
+ throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
}
$regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"';
$result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches);
if (!$result) {
- throw new \UnexpectedValueException('Invalid time limits', 2);
+ throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2);
}
$values = json_decode($value, true);
$time1 = \DateTime::createFromFormat('H:i e', $values[0]);
if ($time1 === false) {
- throw new \UnexpectedValueException('Invalid start time given', 3);
+ throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3);
}
$time2 = \DateTime::createFromFormat('H:i e', $values[1]);
if ($time2 === false) {
- throw new \UnexpectedValueException('Invalid end time given', 3);
+ throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4);
}
}
}