|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Contains Drupal\url_embed\UrlEmbedHelperTrait. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Drupal\url_embed; |
|
9
|
|
|
|
|
10
|
|
|
use Drupal\Core\Extension\ModuleHandlerInterface; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Wrapper methods for URL embedding. |
|
14
|
|
|
* |
|
15
|
|
|
* This utility trait should only be used in application-level code, such as |
|
16
|
|
|
* classes that would implement ContainerInjectionInterface. Services registered |
|
17
|
|
|
* in the Container should not use this trait but inject the appropriate service |
|
18
|
|
|
* directly for easier testing. |
|
19
|
|
|
*/ |
|
20
|
|
|
trait UrlEmbedHelperTrait { |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* The module handler service. |
|
24
|
|
|
* |
|
25
|
|
|
* @var \Drupal\Core\Extension\ModuleHandlerInterface. |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $moduleHandler; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* The URL embed service. |
|
31
|
|
|
* |
|
32
|
|
|
* @var \Drupal\url_embed\UrlEmbedService. |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $url_embed; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Returns the module handler. |
|
38
|
|
|
* |
|
39
|
|
|
* @return \Drupal\Core\Extension\ModuleHandlerInterface |
|
40
|
|
|
* The module handler. |
|
41
|
|
|
*/ |
|
42
|
|
|
protected function moduleHandler() { |
|
43
|
|
|
if (!isset($this->moduleHandler)) { |
|
44
|
|
|
$this->moduleHandler = \Drupal::moduleHandler(); |
|
45
|
|
|
} |
|
46
|
|
|
return $this->moduleHandler; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Sets the module handler service. |
|
51
|
|
|
* |
|
52
|
|
|
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler |
|
53
|
|
|
* The module handler service. |
|
54
|
|
|
* |
|
55
|
|
|
* @return self |
|
56
|
|
|
*/ |
|
57
|
|
|
public function setModuleHandler(ModuleHandlerInterface $module_handler) { |
|
58
|
|
|
$this->moduleHandler = $module_handler; |
|
|
|
|
|
|
59
|
|
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Returns the URL embed service. |
|
64
|
|
|
* |
|
65
|
|
|
* @return \Drupal\url_embed\UrlEmbedInterface |
|
66
|
|
|
* The URL embed service.. |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function urlEmbed() { |
|
69
|
|
|
if (!isset($this->url_embed)) { |
|
70
|
|
|
$this->url_embed = \Drupal::service('url_embed'); |
|
71
|
|
|
} |
|
72
|
|
|
return $this->url_embed; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Sets the URL embed service. |
|
77
|
|
|
* |
|
78
|
|
|
* @param \Drupal\url_embed\UrlEmbedInterface $url_embed |
|
79
|
|
|
* The URL embed service. |
|
80
|
|
|
* |
|
81
|
|
|
* @return self |
|
82
|
|
|
*/ |
|
83
|
|
|
public function setUrlEmbed(UrlEmbedInterface $url_embed) { |
|
84
|
|
|
$this->url_embed = $url_embed; |
|
|
|
|
|
|
85
|
|
|
return $this; |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..