diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-23 16:28:37 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-23 16:28:37 +0100 |
commit | ad4d1caa9e744af57ca58a4e57576533eb682d00 (patch) | |
tree | 37d6c284d2afc7fc62cdf80be419b536ab4ea603 /src/WallabagBundle/Twig/Extension | |
parent | b84a80559a1167b5500fbc5eb4965d3b08b371ef (diff) | |
download | wallabag-ad4d1caa9e744af57ca58a4e57576533eb682d00.tar.gz wallabag-ad4d1caa9e744af57ca58a4e57576533eb682d00.tar.zst wallabag-ad4d1caa9e744af57ca58a4e57576533eb682d00.zip |
move WallabagBundle into Wallabag:CoreBundle
Diffstat (limited to 'src/WallabagBundle/Twig/Extension')
-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 | ||