1 | <?php |
||
3 | class TwigGravatar extends \Twig_Extension { |
||
|
|||
4 | public $baseUrl = "http://www.gravatar.com/"; |
||
5 | public $httpsUrl = "https://secure.gravatar.com/"; |
||
6 | |||
7 | public $filterPrefix = "gr"; |
||
8 | |||
9 | private $filterOptions = array("is_safe" => array("html")); |
||
10 | |||
11 | private $defaults = array( |
||
12 | "404", "mm", "identicon", "monsterid", "wavatar", "retro", "blank" |
||
13 | ); |
||
14 | private $ratings = array( |
||
15 | "g", "pg", "r", "x" |
||
16 | ); |
||
17 | |||
18 | /** |
||
19 | * {@inheritdoc} |
||
20 | */ |
||
21 | public function getFilters(){ |
||
30 | |||
31 | /** |
||
32 | * Get a Gravatar Avatar URL |
||
33 | * @param string $email Gravatar Email address |
||
34 | * @return string Gravatar Avatar URL |
||
35 | * @throws \InvalidArgumentException If $email is invalid |
||
36 | */ |
||
37 | public function avatar($email) { |
||
44 | |||
45 | /** |
||
46 | * Change a Gravatar URL to its Secure version |
||
47 | * @param string $value URL to convert |
||
48 | * @return string Converted URL |
||
49 | * @throws \InvalidArgumentException If $value isn't an existing Gravatar URL |
||
50 | */ |
||
51 | public function https($value) { |
||
59 | |||
60 | /** |
||
61 | * Change the Size of a Gravatar URL |
||
62 | * @param string $value |
||
63 | * @param integer $px |
||
64 | * @return string Sized Gravatar URL |
||
65 | */ |
||
66 | public function size($value, $px = 100) { |
||
78 | |||
79 | /** |
||
80 | * Specify a default Image for when there is no matching Gravatar image. |
||
81 | * @param string $value |
||
82 | * @param string $default Defaults to Mystery Man |
||
83 | * @param boolean $force Always load the default image |
||
84 | * @return string Gravatar URL with a default image. |
||
85 | */ |
||
86 | public function def($value, $default = "mm", $force = false) { |
||
102 | |||
103 | /** |
||
104 | * Specify the maximum rating for an avatar |
||
105 | * @param string $value |
||
106 | * @param string $rating Expects g,pg,r or x |
||
107 | * @return string Gravatar URL with a rating specified |
||
108 | */ |
||
109 | public function rating($value, $rating = "g") { |
||
120 | |||
121 | |||
122 | /** |
||
123 | * Generate the Hashed email address |
||
124 | * @param string $email |
||
125 | * @return string Hashed email address |
||
126 | */ |
||
127 | public function generateHash($email) { |
||
130 | |||
131 | /** |
||
132 | * Generate the query string |
||
133 | * @param string $string |
||
134 | * @param array $addition Array of what parameters to add |
||
135 | * @return string |
||
136 | */ |
||
137 | private function query($string, array $addition) { |
||
143 | |||
144 | /** |
||
145 | * Get the Extension name |
||
146 | * @return string |
||
147 | */ |
||
148 | public function getName() { |
||
151 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.