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