1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @author Russell Michell 2018 <[email protected]> |
5
|
|
|
* @package silverstripe-verifiable |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace PhpTek\Verifiable\Cron; |
9
|
|
|
|
10
|
|
|
use SilverStripe\CronTask\Interfaces\CronTask; |
|
|
|
|
11
|
|
|
use PhpTek\Verifiable\ORM\FieldType\ChainpointProof; |
12
|
|
|
use SilverStripe\ORM\DataObject; |
13
|
|
|
use SilverStripe\Core\Extensible; |
14
|
|
|
use PhpTek\Verifiable\Verify\VerifiableExtension; |
15
|
|
|
use SilverStripe\ORM\DataList; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Assumes of course that the CronTask cron is running on the server. See README. |
19
|
|
|
*/ |
20
|
|
|
class ChainpointFullProofTask implements CronTask |
21
|
|
|
{ |
22
|
|
|
use Extensible; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public function getSchedule() |
28
|
|
|
{ |
29
|
|
|
return '0 1 * * *'; // 01:00 every day |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
* @throws Exception |
35
|
|
|
*/ |
36
|
|
|
public function process() |
37
|
|
|
{ |
38
|
|
|
if (!$backend = $this->verifiableService->getBackend() === 'chainpoint') { |
39
|
|
|
throw new Exception(sprintf('Cannot use %s backend with %s!', $backend, __CLASS__)); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$fullProofs = $this->verifiableService->read($this->getPartials()); |
43
|
|
|
$this->writeFull($fullProofs); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Fetch all partial proofs, ready to make them whole again. The returned |
48
|
|
|
* |
49
|
|
|
* @return array |
50
|
|
|
*/ |
51
|
|
|
protected function getPartials() |
52
|
|
|
{ |
53
|
|
|
// Get decorated classes |
54
|
|
|
$verifiableClasses = array_filter(self::get_extensions(DataObject::class), function($v) { |
|
|
|
|
55
|
|
|
return $v === VerifiableExtension::class; |
56
|
|
|
}); |
57
|
|
|
|
58
|
|
|
// Now fetch the relevant records, filtering on incomplete proofs |
59
|
|
|
DataList::create($args); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Takes a large JSON string, converts it to a ChainpointProof object and |
64
|
|
|
* updates the necessary records. |
65
|
|
|
* |
66
|
|
|
* @param string $fullProofs |
67
|
|
|
* @return void |
68
|
|
|
*/ |
69
|
|
|
protected function writeFull($proofs) |
70
|
|
|
{ |
71
|
|
|
$jsonObject = ChainpointProof::create()->setValue($proofs); |
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths