Exemple #1
0
            return $cached;
        }
        $config = static::$_serviceConfig;
        try {
            $client = new Tumblr($config['consumerKey'], $config['consumerSecret'], $config['token'], $config['tokenSecret']);
            $results = $client->getBlogPosts($config['name'], ['limit' => 2]);
            $results = $results->posts;
        } catch (CurlException $e) {
            return [];
        } catch (Exception $e) {
            return [];
        }
        $results = (new Collection(['data' => $results]))->find(function ($item) {
            return $item->timestamp >= strtotime('-2 months');
        })->each(function ($item) {
            return static::create((array) $item);
        });
        Cache::write('default', $cacheKey, $results, '+1 hour');
        return $results;
    }
    public function teaser($entity)
    {
        $html = $entity->body;
        $html = preg_replace('#\\<div.class\\=.credit.*\\/div\\>#mis', '', $html);
        $html = strip_tags($html);
        $html = Textual::limit($html, 190, ['html' => true]);
        return $html;
    }
}
Posts::init();