summaryrefslogtreecommitdiff
path: root/providers/XmlFeed.php
blob: d5ecd1cdb12a2b445d83cd31763afd40b6eaa6d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

namespace Providers;

require_once('Provider.php');

abstract class XmlFeed extends \Providers\Provider {

    protected $_feedUrl;
    protected $_feedXml;

    abstract protected function _getFeedUrl($feed);

    public function __construct($feed, $options=[]) {
        parent::__construct($feed, $options);
        $this->_feedUrl = $this->_getFeedUrl($feed);
        if (!$this->_feedUrl) {
            throw new Exception('XML feed "' . $feed . '" undefined');
        }
    }

    abstract protected function _parseFeedContent($feed);

    protected function _fetchItems() {
        $this->_feedXml = new \SimpleXMLElement($this->_feedUrl, 0, TRUE);
        return $this->_parseFeedContent($this->_feedXml);
    }

    protected function _spamFilter($content) {
        return $content;
    }

    protected function _sortContent($content) {
        return $content;
    }

}

?>