Conditions | 3 |
Paths | 3 |
Total Lines | 35 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
28 | public function actionSettings(): Response |
||
29 | { |
||
30 | $this->requirePostRequest(); |
||
31 | $this->requireAcceptsJson(); |
||
32 | |||
33 | $view = $this->getView(); |
||
34 | |||
35 | $type = Link::getInstance()->getType()->find( |
||
36 | Craft::$app->getRequest()->getRequiredBodyParam('type') |
||
37 | ); |
||
38 | |||
39 | if (!$type) { |
||
40 | throw new HttpException("Type not found"); |
||
41 | } |
||
42 | |||
43 | // Allow explicit setting of the identifier |
||
44 | if ($identifier = Craft::$app->getRequest()->getBodyParam('identifier')) { |
||
45 | $type->setIdentifier($identifier); |
||
46 | } |
||
47 | |||
48 | $html = $view->renderTemplate( |
||
49 | 'link/_components/fieldtypes/Link/type', |
||
50 | [ |
||
51 | 'type' => $type, |
||
52 | 'namespace' => Craft::$app->getRequest()->getRequiredBodyParam('namespace') |
||
53 | ] |
||
54 | ); |
||
55 | |||
56 | return $this->asJson([ |
||
57 | 'label' => $type::displayName(), |
||
58 | 'paneHtml' => $html, |
||
59 | 'headHtml' => $view->getHeadHtml(), |
||
60 | 'footHtml' => $view->getBodyHtml(), |
||
61 | ]); |
||
62 | } |
||
63 | } |
||
64 |