|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace Riclep\Storyblok\Traits; |
|
5
|
|
|
|
|
6
|
|
|
use Embed\Embed; |
|
7
|
|
|
|
|
8
|
|
|
trait EmbedsMedia |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* The Embed\Embed object. |
|
|
|
|
|
|
12
|
|
|
* |
|
13
|
|
|
* @var Embed\Embed |
|
14
|
|
|
*/ |
|
15
|
|
|
private $_embed; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Initialises the Embed object. |
|
19
|
|
|
*/ |
|
20
|
|
|
protected function init() { |
|
21
|
|
|
$this->_embed = Embed::create($this->content); |
|
|
|
|
|
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Returns the embed code looking for a view in storyblok.embeds or the package. |
|
26
|
|
|
* If neither are found the raw embed code is returned. |
|
27
|
|
|
* |
|
28
|
|
|
* @return string |
|
29
|
|
|
*/ |
|
30
|
|
|
public function html() { |
|
31
|
|
|
if (method_exists($this, 'embedView')) { |
|
32
|
|
|
$method = 'embedView'; |
|
33
|
|
|
} else { |
|
34
|
|
|
$method = 'baseEmbedView'; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
if ($this->{$method}()) { |
|
38
|
|
|
return (string) view($this->{$method}(), [ |
|
39
|
|
|
'embed' => $this->_embed, |
|
40
|
|
|
]); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return $this->rawEmbed(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Returns the raw embed code. |
|
48
|
|
|
* |
|
49
|
|
|
* @return string |
|
50
|
|
|
*/ |
|
51
|
|
|
public function rawEmbed() { |
|
52
|
|
|
return $this->_embed->code; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Returns the Embed\Embed object. |
|
57
|
|
|
* |
|
58
|
|
|
* @return Embed\Embed |
|
59
|
|
|
*/ |
|
60
|
|
|
public function embed() { |
|
61
|
|
|
return $this->_embed; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Returns a path to a view to use for embedding this type of media. |
|
66
|
|
|
* If the view can not be found it should return false. |
|
67
|
|
|
* |
|
68
|
|
|
* @return false|string |
|
69
|
|
|
*/ |
|
70
|
|
|
protected function baseEmbedView() { |
|
71
|
|
|
if (view()->exists(config('storyblok.view_path') . 'embeds.' . strtolower($this->_embed->providerName))) { |
|
72
|
|
|
return config('storyblok.view_path') . 'embeds.' . strtolower($this->_embed->providerName); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
if (view()->exists('laravel-storyblok::embeds.' . strtolower($this->_embed->providerName))) { |
|
76
|
|
|
return 'laravel-storyblok::embeds.' . strtolower($this->_embed->providerName); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return false; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Returns the embed code |
|
85
|
|
|
* |
|
86
|
|
|
* @return string |
|
87
|
|
|
*/ |
|
88
|
|
|
public function __toString() |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->html(); |
|
91
|
|
|
} |
|
92
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths