zendframework/zf2 — pull request #4105 by weierophinney (2013-07-22 16:23:48+00:00)
Title: Method "headLink" does not exist

The following **does not** work:

````php
echo $this->headLink()
->prependStylesheet($this->basePath($cacheBuster->bustPath('assets/css/local/forie.css')), 'screen', 'IE9')
->prependStylesheet($this->basePath($cacheBuster->bustPath('assets/css/application.css')))
->prependStylesheet($this->basePath($cacheBuster->bustPath('assets/css/vendor/responsive.css')))
->prependStylesheet($this->basePath($cacheBuster->bustPath('assets/css/vendor/bootstrap.css')))
->headLink(array(
'rel' => 'shortcut icon',
'type' => 'image/vnd.microsoft.icon',
'href' => $this->basePath('assets/img/favicon.ico')))
->headLink(array(
'rel' => 'author',
'href' => $this->basePath('humans.txt')))
````

The following works:

````php
echo $this->headLink()
->prependStylesheet($this->basePath($cacheBuster->bustPath('assets/css/local/forie.css')), 'screen', 'IE9')
->prependStylesheet($this->basePath($cacheBuster->bustPath('assets/css/application.css')))
->prependStylesheet($this->basePath($cacheBuster->bustPath('assets/css/vendor/responsive.css')))
->prependStylesheet($this->basePath($cacheBuster->bustPath('assets/css/vendor/bootstrap.css')))
->__invoke(array(
'rel' => 'shortcut icon',
'type' => 'image/vnd.microsoft.icon',
'href' => $this-basePath('assets/img/favicon.ico')))
->__invoke(array(
'rel' => 'author',
'href' => $this->basePath('humans.txt')))
````
[The documentation](http://framework.zend.com/manual/1.12/en/zend.view.helpers.html#zend.view.helpers.initial.headlink)–which is, unfortunately, the only documentation available as I don't see any 2.0 version–states:

> Example `#19` HeadLink Helper Basic Usage
> You may specify a `headLink` at any time. Typically, you will specify global links in your layout script, and application specific links in your application view scripts. In your layout script, in the <head> section, you will then echo the helper to output it.

And then gives the following example:

````php
$this->headLink()->appendStylesheet('/styles/basic.css')
->headLink(array('rel' => 'icon',
'href' => '/img/favicon.ico'),
'PREPEND')
->prependStylesheet('/styles/moz.css',
'screen',
true,
array('id' => 'my_stylesheet'));
````

It would seem that, contrary to the documentation and the intent of the accompanying [test case](https://github.com/zendframework/zf2/blob/master/tests/ZendTest/View/Helper/HeadLinkTest.php#L107) (whose method name might contain the typo `headScript` instead of `headLink`), `headLink` **cannot** appear at any time when chaining methods.