summaryrefslogtreecommitdiff
path: root/providers/Beer.php
blob: 0de1a25f3f1bd29a0f73beed46e9d95f0b1b6332 (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
40
41
42
<?php

namespace Providers;

require_once('Facebook.php');

class Beer extends \Providers\Facebook {

    protected $_feedGroup;

    public function __construct($feed, $options=[]) {
        parent::__construct($feed, $options);
        $this->_feedGroup = $feed;
        $this->_groupConfig = json_decode(file_get_contents('../config/beer.json'), TRUE);
    }

    protected function _getCachePath() {
        return '../cache/beer.%s';
    }

    protected function _fetchItems() {
        $data = [];
        foreach ($this->_groupConfig[$this->_feedGroup] as $feed) {
            $this->_feed = $feed;
            $data = array_merge($data, parent::_fetchItems());
        }
        $this->_feed = $this->_feedGroup;
        return $data;
    }

    protected function _sortContent($content) {
        usort($content, function($c1, $c2) { return $c2->Time - $c1->Time; });
        return $content;
    }

    public function title() {
        return sprintf("Beer Facebook page posts - %s", $this->_feed);
    }

}

?>