LiveContentController   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A show() 0 9 1
1
<?php
2
3
namespace Riclep\Storyblok\Http\Controllers;
4
5
use IvoPetkov\HTML5DOMDocument;
6
use Riclep\Storyblok\StoryblokFacade as StoryBlok;
7
use Illuminate\Http\Request;
8
9
class LiveContentController
10
{
11
	/**
12
	 * Used for the live reloading on content in the visual editor. We extract the HTML inside the
13
	 * live_element class and replace the existing DOM elements with the new ones
14
	 *
15
	 * @param Request $request
16
	 * @return string
17
	 * @throws \Exception
18
	 */
19
	public function show(Request $request): string
20
    {
21
		config(['storyblok.edit_mode' => true]);
22
23
		$page = Storyblok::setData($request->get('data')['story'])->render();
0 ignored issues
show
Bug introduced by
The method setData() does not exist on Riclep\Storyblok\StoryblokFacade. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
		$page = Storyblok::/** @scrutinizer ignore-call */ setData($request->get('data')['story'])->render();
Loading history...
24
		$dom = new HTML5DOMDocument();
25
		$dom->loadHTML($page);
26
27
		return $dom->querySelector(config('storyblok.live_element'))->innerHTML;
28
	}
29
}
30