|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* SEOmatic plugin for Craft CMS 3.x |
|
4
|
|
|
* |
|
5
|
|
|
* A turnkey SEO implementation for Craft CMS that is comprehensive, powerful, |
|
6
|
|
|
* and flexible |
|
7
|
|
|
* |
|
8
|
|
|
* @link https://nystudio107.com |
|
9
|
|
|
* @copyright Copyright (c) 2017 nystudio107 |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace nystudio107\seomatic\controllers; |
|
13
|
|
|
|
|
14
|
|
|
use nystudio107\seomatic\helpers\Schema as SchemaHelper; |
|
15
|
|
|
|
|
16
|
|
|
use craft\web\Controller; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @author nystudio107 |
|
20
|
|
|
* @package Seomatic |
|
21
|
|
|
* @since 1.0.0 |
|
22
|
|
|
*/ |
|
23
|
|
|
class JsonLdController extends Controller |
|
24
|
|
|
{ |
|
25
|
|
|
// Properties |
|
26
|
|
|
// ========================================================================= |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @inheritdoc |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $allowAnonymous = [ |
|
32
|
|
|
'get-type', |
|
33
|
|
|
'get-decomposed-type', |
|
34
|
|
|
'get-type-array', |
|
35
|
|
|
'get-type-menu', |
|
36
|
|
|
'get-single-type-menu', |
|
37
|
|
|
]; |
|
38
|
|
|
|
|
39
|
|
|
// Public Methods |
|
40
|
|
|
// ========================================================================= |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Get the fully composed schema type |
|
44
|
|
|
* |
|
45
|
|
|
* @param string $schemaType |
|
46
|
|
|
* |
|
47
|
|
|
* @return \yii\web\Response |
|
48
|
|
|
*/ |
|
49
|
|
|
public function actionGetType($schemaType) |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->asJson(SchemaHelper::getSchemaType($schemaType)); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Get the decomposed schema type |
|
56
|
|
|
* |
|
57
|
|
|
* @param string $schemaType |
|
58
|
|
|
* |
|
59
|
|
|
* @return \yii\web\Response |
|
60
|
|
|
*/ |
|
61
|
|
|
public function actionGetDecomposedType($schemaType) |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->asJson(SchemaHelper::getDecomposedSchemaType($schemaType)); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Get an array of schema types |
|
68
|
|
|
* |
|
69
|
|
|
* @param string $path |
|
70
|
|
|
* |
|
71
|
|
|
* @return \yii\web\Response |
|
72
|
|
|
*/ |
|
73
|
|
|
public function actionGetTypeArray($path) |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->asJson(SchemaHelper::getSchemaArray($path)); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Get a flattened menu of schema types as an array |
|
80
|
|
|
* |
|
81
|
|
|
* @param string $path |
|
82
|
|
|
* |
|
83
|
|
|
* @return \yii\web\Response |
|
84
|
|
|
*/ |
|
85
|
|
|
public function actionGetTypeMenu($path) |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->asJson(SchemaHelper::getSchemaMenu($path)); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Return a single menu of schemas starting at $path |
|
92
|
|
|
* |
|
93
|
|
|
* @param string $path |
|
94
|
|
|
* |
|
95
|
|
|
* @return \yii\web\Response |
|
96
|
|
|
*/ |
|
97
|
|
|
public function actionGetSingleTypeMenu($path) |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->asJson(SchemaHelper::getSingleSchemaMenu($path)); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|