|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Digia\Lumen\ContentfulSync\Services; |
|
4
|
|
|
|
|
5
|
|
|
use Digia\Lumen\ContentfulSync\Jobs\ContentfulDeleteAssetJob; |
|
6
|
|
|
use Digia\Lumen\ContentfulSync\Jobs\ContentfulDeleteEntryJob; |
|
7
|
|
|
use Digia\Lumen\ContentfulSync\Jobs\ContentfulPublishAssetJob; |
|
8
|
|
|
use Digia\Lumen\ContentfulSync\Jobs\ContentfulPublishEntryJob; |
|
9
|
|
|
use Illuminate\Contracts\Queue\Queue; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class AbstractContentfulSyncService |
|
13
|
|
|
* @package Digia\Lumen\ContentfulSync\Services |
|
14
|
|
|
*/ |
|
15
|
|
|
abstract class AbstractContentfulSyncService |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var Queue |
|
20
|
|
|
*/ |
|
21
|
|
|
private $queue; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @param string $contentType |
|
25
|
|
|
* @param string $entryJson |
|
26
|
|
|
* @param bool $ignoreExisting |
|
27
|
|
|
*/ |
|
28
|
|
|
abstract public function handleEntryPublished(string $contentType, string $entryJson, bool $ignoreExisting); |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param string $contentType |
|
32
|
|
|
* @param string $entryId |
|
33
|
|
|
*/ |
|
34
|
|
|
abstract public function handleEntryDeleted(string $contentType, string $entryId); |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param string $assetJson |
|
38
|
|
|
* @param bool $ignoreExisting |
|
39
|
|
|
*/ |
|
40
|
|
|
abstract public function handleAssetPublished(string $assetJson, bool $ignoreExisting); |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param string $assetId |
|
44
|
|
|
*/ |
|
45
|
|
|
abstract public function handleAssetDeleted(string $assetId); |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* ContentfulSyncService constructor. |
|
49
|
|
|
* |
|
50
|
|
|
* @param Queue $queue |
|
51
|
|
|
*/ |
|
52
|
|
|
public function __construct(Queue $queue) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->queue = $queue; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param string $contentType |
|
59
|
|
|
* @param string $entryJson |
|
60
|
|
|
* @param bool $ignoreExisting |
|
61
|
|
|
* |
|
62
|
|
|
* @suppress PhanTypeMismatchArgument see https://github.com/laravel/framework/pull/21248 |
|
63
|
|
|
*/ |
|
64
|
|
|
public function publishEntry(string $contentType, string $entryJson, bool $ignoreExisting = false): void |
|
65
|
|
|
{ |
|
66
|
|
|
$this->queue->push(new ContentfulPublishEntryJob($contentType, $entryJson, $ignoreExisting)); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param string $contentType |
|
71
|
|
|
* @param string $entryId |
|
72
|
|
|
* |
|
73
|
|
|
* @suppress PhanTypeMismatchArgument see https://github.com/laravel/framework/pull/21248 |
|
74
|
|
|
*/ |
|
75
|
|
|
public function deleteEntry(string $contentType, string $entryId): void |
|
76
|
|
|
{ |
|
77
|
|
|
$this->queue->push(new ContentfulDeleteEntryJob($contentType, $entryId)); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param string $assetJson |
|
82
|
|
|
* @param bool $ignoreExisting |
|
83
|
|
|
* |
|
84
|
|
|
* @suppress PhanTypeMismatchArgument see https://github.com/laravel/framework/pull/21248 |
|
85
|
|
|
*/ |
|
86
|
|
|
public function publishAsset(string $assetJson, bool $ignoreExisting = false): void |
|
87
|
|
|
{ |
|
88
|
|
|
$this->queue->push(new ContentfulPublishAssetJob($assetJson, $ignoreExisting)); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @param string $assetId |
|
93
|
|
|
* |
|
94
|
|
|
* @suppress PhanTypeMismatchArgument see https://github.com/laravel/framework/pull/21248 |
|
95
|
|
|
*/ |
|
96
|
|
|
public function deleteAsset(string $assetId): void |
|
97
|
|
|
{ |
|
98
|
|
|
$this->queue->push(new ContentfulDeleteAssetJob($assetId)); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|