From 19860865d169a3aa02813fe886766f32066504a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Peri=C4=87?= Date: Tue, 7 Apr 2015 20:45:59 +0200 Subject: [PATCH 1/3] Update HtmlBuilder.php Add support for Favicon files. --- src/HtmlBuilder.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/HtmlBuilder.php b/src/HtmlBuilder.php index 44954d3..1e9f797 100755 --- a/src/HtmlBuilder.php +++ b/src/HtmlBuilder.php @@ -96,6 +96,25 @@ class HtmlBuilder { return '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 'attributes($attributes).'>'.PHP_EOL; + } /** * Generate a HTML link. From c3a3a44a3725acbcdb4af744f5deb2d6ca9804b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Peri=C4=87?= Date: Tue, 7 Apr 2015 21:43:57 +0200 Subject: [PATCH 2/3] Added test --- tests/HtmlBuilderTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/HtmlBuilderTest.php b/tests/HtmlBuilderTest.php index 2f2cc75..f2c18cd 100644 --- a/tests/HtmlBuilderTest.php +++ b/tests/HtmlBuilderTest.php @@ -55,4 +55,13 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase { $this->assertEquals(''.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('' . PHP_EOL, $result); + } + } \ No newline at end of file From 52e297e67964c16a68569d21cf9ce6f64bfe8638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Peri=C4=87?= Date: Tue, 7 Apr 2015 22:06:26 +0200 Subject: [PATCH 3/3] Newline at the end of the file --- tests/HtmlBuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/HtmlBuilderTest.php b/tests/HtmlBuilderTest.php index f2c18cd..9e32201 100644 --- a/tests/HtmlBuilderTest.php +++ b/tests/HtmlBuilderTest.php @@ -64,4 +64,4 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase { $this->assertEquals('' . PHP_EOL, $result); } -} \ No newline at end of file +}