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

Method "headLink" does not exist #4105

Merged
merged 1 commit into from
Jul 22, 2013

Conversation

weierophinney
Copy link
Member

The following does not work:

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:

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–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:

$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 (whose method name might contain the typo headScript instead of headLink), headLink cannot appear at any time when chaining methods.

@macnibblet
Copy link
Contributor

A simple fix would be to add a proxy method headLink on the helper to call __invoke but imho it would be better to change the documentation. Since that would create less confussion.

@Maks3w
Copy link
Member

Maks3w commented Jul 17, 2013

I agree with to add a proxy method called headLink. Do you want to send a pull request?

- Creates a proxy "headLink" method which allows us usage as described
  in the manual. Proxies to `__invoke`.
@ezimuel ezimuel merged commit 28a4760 into zendframework:master Jul 22, 2013
weierophinney added a commit to zendframework/zend-view that referenced this pull request May 15, 2015
- Creates a proxy "headLink" method which allows us usage as described
  in the manual. Proxies to `__invoke`.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants