Skip to content
This repository has been archived by the owner on Mar 14, 2020. It is now read-only.

Commit

Permalink
added "secure" as another defaults config option
Browse files Browse the repository at this point in the history
  • Loading branch information
dVelopment committed Sep 5, 2013
1 parent 1bfb059 commit d2e7ad2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function getConfigTree()
->scalarNode('size')->defaultValue('80')->end()
->scalarNode('rating')->defaultValue('g')->end()
->scalarNode('default')->defaultValue('mm')->end()
->booleanNode('secure')->defaultFalse()->end()
->end();

return $treeBuilder->buildTree();
Expand Down
9 changes: 7 additions & 2 deletions GravatarApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class GravatarApi
'size' => 80,
'rating' => 'g',
'default' => null,
'secure' => false,
);

/**
Expand All @@ -44,7 +45,7 @@ public function __construct(array $options = array())
* @param Boolean $secure
* @return string
*/
public function getUrl($email, $size = null, $rating = null, $default = null, $secure = false)
public function getUrl($email, $size = null, $rating = null, $default = null, $secure = null)
{
$hash = md5(strtolower(trim($email)));

Expand All @@ -61,14 +62,18 @@ public function getUrl($email, $size = null, $rating = null, $default = null, $s
* @param Boolean $secure
* @return string
*/
public function getUrlForHash($hash, $size = null, $rating = null, $default = null, $secure = false)
public function getUrlForHash($hash, $size = null, $rating = null, $default = null, $secure = null)
{
$map = array(
's' => $size ?: $this->defaults['size'],
'r' => $rating ?: $this->defaults['rating'],
'd' => $default ?: $this->defaults['default'],
);

if (null === $secure) {
$secure = $this->defaults['secure'];
}

return ($secure ? 'https://secure' : 'http://www') . '.gravatar.com/avatar/' . $hash . '?' . http_build_query(array_filter($map));
}

Expand Down

0 comments on commit d2e7ad2

Please sign in to comment.