-
Notifications
You must be signed in to change notification settings - Fork 617
Expand file tree
/
Copy pathAbstractStep.php
More file actions
84 lines (67 loc) · 1.98 KB
/
Copy pathAbstractStep.php
File metadata and controls
84 lines (67 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/*
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
More about this license: http://www.question2answer.org/license.php
*/
abstract class Q2A_Admin_Recalc_AbstractStep
{
/** @var int|null */
protected $processedItems = 0;
/** @var int|null */
protected $totalItems;
/** @var mixed */
protected $nextItemId = 0;
/** @var mixed */
protected $lastProcessedItemId = 0;
/** @var bool */
protected $isFinished = false;
/** @var string */
protected $messageLangId = '';
abstract public function setup();
abstract public function execute();
/**
* @return array
*/
public function asArray()
{
return [
'is_finished' => $this->isFinished,
'processed_items' => $this->processedItems,
'total_items' => $this->totalItems,
'next_item_id' => $this->nextItemId,
'last_processed_item_id' => $this->lastProcessedItemId,
];
}
public function loadFromJson($state)
{
$this->isFinished = $state['is_finished'];
$this->processedItems = $state['processed_items'];
$this->totalItems = $state['total_items'];
$this->nextItemId = $state['next_item_id'];
$this->lastProcessedItemId = $state['last_processed_item_id'];
}
/**
* @return bool
*/
public function isFinished()
{
return $this->isFinished;
}
public function getMessage()
{
require_once QA_INCLUDE_DIR . 'app/format.php';
return strtr(qa_lang($this->messageLangId), array(
'^1' => qa_format_number($this->processedItems),
'^2' => qa_format_number($this->totalItems),
));
}
}