1 | <?php |
||
12 | class DiscoveryProvider implements ProviderInterface |
||
13 | { |
||
14 | const LINK_ANY_XPATH = '//head/link[@rel = \'alternate\' and (@type = \'application/json+oembed\' or @type = \'text/xml+oembed\')]'; |
||
15 | const LINK_JSON_XPATH = '//head/link[@rel = \'alternate\' and @type = \'application/json+oembed\']'; |
||
16 | const LINK_XML_XPATH = '//head/link[@rel = \'alternate\' and @type = \'text/xml+oembed\']'; |
||
17 | |||
18 | /** |
||
19 | * @var ClientInterface |
||
20 | */ |
||
21 | private $client; |
||
22 | |||
23 | /** |
||
24 | * @var FormatNegotiatorInterface |
||
25 | */ |
||
26 | private $negotiator; |
||
27 | |||
28 | /** |
||
29 | * @param ClientInterface $client |
||
30 | * @param FormatNegotiatorInterface $negotiator |
||
31 | */ |
||
32 | 68 | public function __construct(ClientInterface $client, FormatNegotiatorInterface $negotiator) |
|
37 | |||
38 | /** |
||
39 | * Returns whether this class supports the given resource. |
||
40 | * |
||
41 | * @param string $url A url |
||
42 | * @param array $params The resource type or null if unknown |
||
43 | * |
||
44 | * @return bool True if this class supports the given url, false otherwise |
||
45 | */ |
||
46 | 60 | public function supports($url, array $params = array()) |
|
52 | |||
53 | /** |
||
54 | * @param $url |
||
55 | * @param array $params |
||
56 | * |
||
57 | * @return Psr7\Request |
||
58 | */ |
||
59 | 50 | public function request($url, array $params = array()) |
|
67 | |||
68 | /** |
||
69 | * @param string $url |
||
70 | * @param array $params |
||
71 | * |
||
72 | * @return array |
||
73 | */ |
||
74 | 68 | private function discoverLinks($url, array $params = array()) |
|
90 | |||
91 | /** |
||
92 | * @param $format |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | 14 | private static function xpathForFormat($format) |
|
108 | |||
109 | /** |
||
110 | * @param ResponseInterface $response |
||
111 | * @param string $xpath |
||
112 | * |
||
113 | * @return array |
||
114 | */ |
||
115 | 66 | private static function responseBodyOEmbedLinks(ResponseInterface $response, $xpath) |
|
122 | } |
||
123 |