| Total Complexity | 9 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | trait SchemaOrg |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Automatically called to add a schema to the Page |
||
| 13 | */ |
||
| 14 | protected function initSchemaOrg(): void |
||
| 15 | { |
||
| 16 | if (method_exists($this, 'schemaOrg')) { |
||
| 17 | if ($this instanceof Page) { |
||
| 18 | $page = $this; |
||
| 19 | } else { |
||
| 20 | $page = $this->page(); |
||
|
|
|||
| 21 | } |
||
| 22 | |||
| 23 | if ($page && count($this->_componentPath) <= config('storyblok.schema_org_depth')) { |
||
| 24 | $this->addschemaOrg($page); |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Returns the JavaScript JSON-LD string |
||
| 32 | * |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | public function schemaOrgScript(): string |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Adds the schema to the meta of the current page |
||
| 48 | * |
||
| 49 | * @param $page |
||
| 50 | */ |
||
| 51 | protected function addschemaOrg($page): void |
||
| 62 |