-
Notifications
You must be signed in to change notification settings - Fork 61
Asset helper #64
Asset helper #64
Conversation
This looks like a nice solution in terms of being light-weight, and integrating with established front-end workflows. My one comment: I wonder if this should integrate with <?= $this->basePath($this->asset('css/style.css')) ?> In particular, the use of relative URLs in the resource map may be problematic when on a path that represents more than one level deep in the tree (e.g., '/foo/bar/baz' would make 'css/style.css' resolve to '/foo/bar/css/style.css' on most browsers). If the asset paths are expected to be relative to the application root, we need to either enforce that within the helper, or document that the developer is responsible for this. Thoughts? |
@weierophinney good point. I thought about it, and I think developer should be responsible to ensure he has a good paths. We can add into documentation example with I think better if we allow decide developers how they want use it. Probably it will be used mostly with plugins
and in view:
It's hard to say how it will be used, but I think without integration with BTW. How you'd like to use one plugin inside another? Pass it via factory? |
doc/book/helpers/asset.md
Outdated
which will be replaced by versioned asset name defined in `resource_map` | ||
of the configuration. | ||
|
||
### Note |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put the note in a blockqoute.
> ### Note
> ...
src/Helper/Asset.php
Outdated
return $this->resourceMap[$asset]; | ||
} | ||
|
||
public function setResourceMap($resourceMap) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a full DocBlock. (description, parameter, return value)
src/Helper/Asset.php
Outdated
return $this; | ||
} | ||
|
||
public function getResourceMap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
/** | ||
* View helper plugin to fetch asset from resource map. | ||
*/ | ||
class Asset extends AbstractHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the helper in the DocBlock of PhpRenderer
for code completion in IDEs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 3e08baf
- per @froschdesign
- First publication in a release is gonna be this year (I hope so...)
@froschdesign I've made all requested changes and added also a few fixes |
Thanks, @webimpress |
Asset view helper. It required resource map (array) configuration. Can be used also with JSON file (eg. generated by gulp/grunt - rev-manifest.json) as described in docs.
I am not 100% happy with tests because of confusing compatibility with zend-servicemanager v2 and v3.
Any suggestions would be appreciated.