Merge pull request #26 from toniperic/patch-1
Add support for Favicon files
This commit is contained in:
commit
4edbd282ba
2 files changed
+29
-1
No files matched your search
@@ -96,6 +96,25 @@ class HtmlBuilder {
|
||||
|
||||
return '<img src="'.$this->url->asset($url, $secure).'"'.$this->attributes($attributes).'>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a link to a Favicon file.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $attributes
|
||||
* @param bool $secure
|
||||
* @return string
|
||||
*/
|
||||
public function favicon($url, $attributes = array(), $secure = null)
|
||||
{
|
||||
$defaults = array('rel' => 'shortcut icon', 'type' => 'image/x-icon');
|
||||
|
||||
$attributes = $attributes + $defaults;
|
||||
|
||||
$attributes['href'] = $this->url->asset($url, $secure);
|
||||
|
||||
return '<link'.$this->attributes($attributes).'>'.PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a HTML link.
|
||||
|
||||
@@ -55,4 +55,13 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase {
|
||||
$this->assertEquals('<meta content="website" property="og:type">'.PHP_EOL, $result);
|
||||
}
|
||||
|
||||
}
|
||||
public function testFavicon()
|
||||
{
|
||||
$this->urlGenerator->forceRootUrl('http://foo.com');
|
||||
$target = $this->urlGenerator->to('bar.ico');
|
||||
$result = $this->htmlBuilder->favicon('http://foo.com/bar.ico');
|
||||
|
||||
$this->assertEquals('<link rel="shortcut icon" type="image/x-icon" href="'.$target.'">' . PHP_EOL, $result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user