diff options
Diffstat (limited to 'src/WallabagBundle/Twig')
-rw-r--r-- | src/WallabagBundle/Twig/Extension/WallabagExtension.php | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/src/WallabagBundle/Twig/Extension/WallabagExtension.php b/src/WallabagBundle/Twig/Extension/WallabagExtension.php deleted file mode 100644 index 741fb191..00000000 --- a/src/WallabagBundle/Twig/Extension/WallabagExtension.php +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace WallabagBundle\Twig\Extension; | ||
4 | |||
5 | class WallabagExtension extends \Twig_Extension | ||
6 | { | ||
7 | public function getFilters() | ||
8 | { | ||
9 | return array( | ||
10 | new \Twig_SimpleFilter('readingTime', array($this, 'getReadingTime')), | ||
11 | new \Twig_SimpleFilter('domainName', array($this, 'getDomainName')), | ||
12 | ); | ||
13 | } | ||
14 | |||
15 | /** | ||
16 | * Returns the domain name for a URL | ||
17 | * | ||
18 | * @param $url | ||
19 | * @return string | ||
20 | */ | ||
21 | public static function getDomainName($url) | ||
22 | { | ||
23 | return parse_url($url, PHP_URL_HOST); | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * For a given text, we calculate reading time for an article | ||
28 | * | ||
29 | * @param $text | ||
30 | * @return float | ||
31 | */ | ||
32 | public static function getReadingTime($text) | ||
33 | { | ||
34 | return floor(str_word_count(strip_tags($text)) / 200); | ||
35 | } | ||
36 | |||
37 | public function getName() | ||
38 | { | ||
39 | return 'wallabag_extension'; | ||
40 | } | ||
41 | } \ No newline at end of file | ||