diff --git a/src/Helper/HeadLink.php b/src/Helper/HeadLink.php index d43aa771..ca4ec6f5 100644 --- a/src/Helper/HeadLink.php +++ b/src/Helper/HeadLink.php @@ -56,6 +56,21 @@ public function __construct() $this->setSeparator(PHP_EOL); } + /** + * Proxy to __invoke() + * + * Allows calling $helper->headLink(), but, more importantly, chaining calls + * like ->appendStylesheet()->headLink(). + * + * @param array $attributes + * @param string $placement + * @return HeadLink + */ + public function headLink(array $attributes = null, $placement = Placeholder\Container\AbstractContainer::APPEND) + { + return call_user_func_array(array($this, '__invoke'), func_get_args()); + } + /** * headLink() - View Helper Method * diff --git a/test/Helper/HeadLinkTest.php b/test/Helper/HeadLinkTest.php index cae38d11..df295f03 100644 --- a/test/Helper/HeadLinkTest.php +++ b/test/Helper/HeadLinkTest.php @@ -92,16 +92,16 @@ public function testOffsetSetThrowsExceptionWithoutArrayArgument() $this->helper->offsetSet(1, 'foo'); } - public function testCreatingLinkStackViaHeadScriptCreatesAppropriateOutput() + public function testCreatingLinkStackViaHeadLinkCreatesAppropriateOutput() { $links = array( 'link1' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'foo'), 'link2' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'bar'), 'link3' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'baz'), ); - $this->helper->__invoke($links['link1']) - ->__invoke($links['link2'], 'PREPEND') - ->__invoke($links['link3']); + $this->helper->headLink($links['link1']) + ->headLink($links['link2'], 'PREPEND') + ->headLink($links['link3']); $string = $this->helper->toString(); $lines = substr_count($string, PHP_EOL);