Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2018-08-18 13:30:22 +0300
committerMaxence Lange <maxence@artificial-owl.com>2018-08-18 13:30:22 +0300
commitc541693b0f400251d613e6ba8c7ca26899e93e92 (patch)
tree829481aa615ddec7f5c0ecd7a6b3633917804b2a /lib/Model/Runner.php
parent44a5fa48fef0adb9389ef1ee2a7c65e11575d9e4 (diff)
info & error
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Model/Runner.php')
-rw-r--r--lib/Model/Runner.php70
1 files changed, 68 insertions, 2 deletions
diff --git a/lib/Model/Runner.php b/lib/Model/Runner.php
index 153abfe..b29be19 100644
--- a/lib/Model/Runner.php
+++ b/lib/Model/Runner.php
@@ -81,6 +81,9 @@ class Runner {
/** @var array */
private $methodOnInfoUpdate = [];
+ /** @var array */
+ private $methodOnIndexError = [];
+
/** @var bool */
private $paused = false;
@@ -191,9 +194,11 @@ class Runner {
/**
* @param string $info
* @param string $value
+ * @param string $colored
*/
- public function setInfo($info, $value) {
+ public function setInfo($info, $value, $colored = '') {
$this->info[$info] = $value;
+ $this->setInfoColored($info, $value, $colored);
$this->infoUpdated();
}
@@ -210,6 +215,40 @@ class Runner {
$this->infoUpdated();
}
+ private function setInfoColored($info, $value, $colored) {
+ if ($colored === '') {
+ return;
+ }
+
+ $color = '';
+ switch ($colored) {
+ case 'success':
+ $color = 'info';
+ break;
+
+ case 'fail' :
+ $color = 'error';
+ break;
+
+ case 'warning':
+ $color = 'comment';
+ break;
+ }
+
+ if ($color !== '') {
+ $this->info[$info . 'Colored'] = '<' . $color . '>' . $value . '</' . $color . '>';
+ }
+
+
+ }
+
+ /**
+ * @return array
+ */
+ public function getInfo() {
+ return $this->info;
+ }
+
/**
* @param array $method
@@ -236,7 +275,7 @@ class Runner {
}
/**
- * @param $key
+ * @param string $action
*/
public function newAction($action) {
foreach ($this->methodOnNewAction as $method) {
@@ -263,6 +302,33 @@ class Runner {
/**
+ * @param array $method
+ */
+ public function onNewIndexError($method) {
+ $this->methodOnIndexError[] = $method;
+ }
+
+ /**
+ * @param Index $index
+ * @param string $message
+ * @param string $class
+ * @param int $sev
+ */
+ public function newIndexError($index, $message, $class = '', $sev = 3) {
+ $error = [
+ 'index' => $index,
+ 'message' => $message,
+ 'exception' => $class,
+ 'severity' => $sev
+ ];
+
+ foreach ($this->methodOnIndexError as $method) {
+ call_user_func($method, $error);
+ }
+ }
+
+
+ /**
* @throws InterruptException
*/
private function hasBeenInterrupted() {