1 | <?php |
||
19 | class Media extends RuleAbstract |
||
20 | { |
||
21 | |||
22 | const NODE_NAME = 'enclosure'; |
||
23 | |||
24 | protected $urlAttributeName = 'url'; |
||
25 | |||
26 | /** |
||
27 | * @return string |
||
28 | */ |
||
29 | 5 | public function getUrlAttributeName() |
|
30 | { |
||
31 | 5 | return $this->urlAttributeName; |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param string $name |
||
36 | * @return $this |
||
37 | */ |
||
38 | 8 | public function setUrlAttributeName($name) |
|
39 | { |
||
40 | 8 | $this->urlAttributeName = $name; |
|
41 | |||
42 | 8 | return $this; |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param NodeInterface $node |
||
47 | * @param \DOMElement $element |
||
48 | * @return $this |
||
49 | */ |
||
50 | 4 | public function setProperty(NodeInterface $node, \DOMElement $element) |
|
51 | { |
||
52 | 4 | if ($node instanceof ItemInterface) { |
|
53 | 4 | $media = $node->newMedia(); |
|
54 | 4 | $media->setType($this->getAttributeValue($element, 'type')) |
|
55 | 4 | ->setUrl($this->getAttributeValue($element, $this->getUrlAttributeName())) |
|
56 | 4 | ->setLength($this->getAttributeValue($element, 'length')); |
|
57 | |||
58 | 4 | $node->addMedia($media); |
|
59 | 4 | } |
|
60 | |||
61 | 4 | return $this; |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * creates the accurate DomElement content according to the $item's property |
||
66 | * |
||
67 | * @param \DomDocument $document |
||
68 | * @param NodeInterface $node |
||
69 | * @return \DomElement |
||
70 | */ |
||
71 | 2 | public function createElement(\DomDocument $document, NodeInterface $node) |
|
81 | |||
82 | /** |
||
83 | * @param \DomDocument $document |
||
84 | * @param MediaInterface $media |
||
85 | * @return \DomElement |
||
86 | */ |
||
87 | 1 | public function createMediaElement(\DomDocument $document, MediaInterface $media) |
|
96 | } |
||
97 |