1 | <?php |
||
22 | class ContentfulSyncController extends Controller |
||
23 | { |
||
24 | |||
25 | protected const TOPIC_CONTENT_MANAGEMENT_ASSET_PUBLISH = 'ContentManagement.Asset.publish'; |
||
26 | protected const TOPIC_CONTENT_MANAGEMENT_ASSET_UNPUBLISH = 'ContentManagement.Asset.unpublish'; |
||
27 | protected const TOPIC_CONTENT_MANAGEMENT_ASSET_DELETE = 'ContentManagement.Asset.delete'; |
||
28 | protected const TOPIC_CONTENT_MANAGEMENT_ENTRY_PUBLISH = 'ContentManagement.Entry.publish'; |
||
29 | protected const TOPIC_CONTENT_MANAGEMENT_ENTRY_UNPUBLISH = 'ContentManagement.Entry.unpublish'; |
||
30 | protected const TOPIC_CONTENT_MANAGEMENT_ENTRY_DELETE = 'ContentManagement.Entry.delete'; |
||
31 | |||
32 | /** |
||
33 | * @var ContentfulServiceContract |
||
34 | */ |
||
35 | private $contentfulService; |
||
36 | |||
37 | /** |
||
38 | * @var ContentfulSyncServiceContract |
||
39 | */ |
||
40 | private $contentfulSyncService; |
||
41 | |||
42 | /** |
||
43 | * ContentfulSyncController constructor. |
||
44 | * |
||
45 | * @param ContentfulServiceContract $contentfulService |
||
46 | * @param ContentfulSyncServiceContract $contentfulSyncService |
||
47 | */ |
||
48 | public function __construct( |
||
55 | |||
56 | /** |
||
57 | * @param Request $request |
||
58 | * |
||
59 | * @return Response |
||
60 | * |
||
61 | * @throws \InvalidArgumentException if the space or environment ID is invalid |
||
62 | * @throws ContentfulSyncException if the webhook cannot be handled |
||
63 | */ |
||
64 | public function handleIncomingWebhook(Request $request): Response |
||
107 | |||
108 | /** |
||
109 | * Parse the specified request content into a Contentful SDK resource |
||
110 | * |
||
111 | * @param string $resourceContent |
||
112 | * |
||
113 | * @return ResourceInterface|ResourceArray |
||
114 | */ |
||
115 | private function parseRequestContent(string $resourceContent) |
||
122 | |||
123 | /** |
||
124 | * @param Entry $entry |
||
125 | * |
||
126 | * @return string |
||
127 | */ |
||
128 | private function getEntryContentType(Entry $entry): string |
||
132 | |||
133 | /** |
||
134 | * @param ResourceInterface $resource |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | private function getResourceId(ResourceInterface $resource): string |
||
142 | |||
143 | /** |
||
144 | * @param Request $request |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | private function getContentfulTopic(Request $request): string |
||
152 | } |
||
153 |