|
@@ -4,48 +4,33 @@ namespace Muzich\CoreBundle\Factory\Elements;
|
4
|
4
|
|
5
|
5
|
use Muzich\CoreBundle\Factory\ElementFactory;
|
6
|
6
|
use Muzich\CoreBundle\Entity\Element;
|
|
7
|
+use Muzich\CoreBundle\Factory\UrlMatchs;
|
|
8
|
+use Symfony\Component\DependencyInjection\Container;
|
|
9
|
+use Doctrine\ORM\EntityManager;
|
7
|
10
|
|
8
|
|
-/**
|
9
|
|
- *
|
10
|
|
- *
|
11
|
|
- * @author bux
|
12
|
|
- */
|
13
|
11
|
class Vimeocom extends ElementFactory
|
14
|
12
|
{
|
15
|
13
|
|
16
|
|
- public function retrieveDatas()
|
|
14
|
+ public function __construct(Element $element, Container $container, EntityManager $entity_manager)
|
17
|
15
|
{
|
18
|
|
- $url_clean = $this->getCleanedUrl();
|
19
|
|
- $ref_id = null;
|
20
|
|
-
|
21
|
|
- // http://vimeo.com/43258820
|
22
|
|
- if (preg_match("#\/([0-9]+)#", $url_clean, $chaines))
|
23
|
|
- {
|
24
|
|
- $ref_id = $chaines[1];
|
25
|
|
- }
|
26
|
|
-
|
27
|
|
- if ($ref_id)
|
28
|
|
- {
|
29
|
|
- $this->element->setData(Element::DATA_REF_ID, $ref_id);
|
30
|
|
- $this->getDataFromApi($ref_id);
|
31
|
|
- }
|
|
16
|
+ $this->url_matchs = UrlMatchs::$vimeo;
|
|
17
|
+ parent::__construct($element, $container, $entity_manager);
|
32
|
18
|
}
|
33
|
19
|
|
34
|
|
- protected function getDataFromApi($ref_id)
|
|
20
|
+ public function proceedDatas()
|
35
|
21
|
{
|
36
|
|
- $data = $this->getJsonDataFromApiWithUrl('http://vimeo.com/api/v2/video/'.$ref_id.'.json');
|
37
|
|
-
|
38
|
|
- if (count($data))
|
39
|
|
- {
|
40
|
|
- if (array_key_exists('title', $data[0]))
|
41
|
|
- {
|
42
|
|
- $this->element->setData(Element::DATA_TITLE, $data[0]['title']);
|
43
|
|
- }
|
44
|
|
- if (array_key_exists('thumbnail_medium', $data[0]))
|
45
|
|
- {
|
46
|
|
- $this->element->setData(Element::DATA_THUMB_URL, $data[0]['thumbnail_medium']);
|
47
|
|
- }
|
48
|
|
- }
|
|
22
|
+ $this->setElementDatasWithApi();
|
|
23
|
+ $this->proceedEmbedCode();
|
|
24
|
+ $this->proceedThumbnailUrl();
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ protected function setElementDatasWithApi()
|
|
28
|
+ {
|
|
29
|
+ $response = $this->getApiConnector()->getResponseForUrl('http://vimeo.com/api/v2/video/'.$this->url_analyzer->getRefId().'.json');
|
|
30
|
+ $this->getApiConnector()->setElementDatasWithResponse($response, array(
|
|
31
|
+ Element::DATA_TITLE => array(0 => 'title'),
|
|
32
|
+ Element::DATA_THUMB_URL => array(0 => 'thumbnail_medium')
|
|
33
|
+ ));
|
49
|
34
|
}
|
50
|
35
|
|
51
|
36
|
public function proceedEmbedCode()
|
|
@@ -61,4 +46,12 @@ class Vimeocom extends ElementFactory
|
61
|
46
|
);
|
62
|
47
|
}
|
63
|
48
|
}
|
|
49
|
+
|
|
50
|
+ public function proceedThumbnailUrl()
|
|
51
|
+ {
|
|
52
|
+ if (($thumb = $this->element->getData(Element::DATA_THUMB_URL)))
|
|
53
|
+ {
|
|
54
|
+ $this->element->setThumbnailUrl($thumb);
|
|
55
|
+ }
|
|
56
|
+ }
|
64
|
57
|
}
|