| Total Complexity | 5 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | trait JsonLdContextTrait |
||
| 27 | { |
||
| 28 | /** |
||
| 29 | * Updates the given JSON-LD document to add its @context key. |
||
| 30 | */ |
||
| 31 | private function addJsonLdContext(ContextBuilderInterface $contextBuilder, string $resourceClass, array &$context, array $data = []): array |
||
| 32 | { |
||
| 33 | if (isset($context['jsonld_has_context'])) { |
||
| 34 | return $data; |
||
| 35 | } |
||
| 36 | |||
| 37 | $context['jsonld_has_context'] = true; |
||
| 38 | |||
| 39 | if (isset($context['jsonld_embed_context'])) { |
||
| 40 | $data['@context'] = $contextBuilder->getResourceContext($resourceClass); |
||
| 41 | |||
| 42 | return $data; |
||
| 43 | } |
||
| 44 | |||
| 45 | $data['@context'] = $contextBuilder->getResourceContextUri($resourceClass); |
||
| 46 | |||
| 47 | return $data; |
||
| 48 | } |
||
| 49 | |||
| 50 | private function createJsonLdContext(AnonymousContextBuilderInterface $contextBuilder, $object, array &$context, array $data = []): array |
||
| 59 | } |
||
| 60 | } |
||
| 61 |