Pulling asset file handling together

37 views
Skip to first unread message

Schlaefer

unread,
Nov 12, 2013, 4:40:51 PM11/12/13
to cakeph...@googlegroups.com

I dug into asset handling recently and thought it might be a good idea to consolidate asset handling (resolve url/path according to theme/plugin) into a separate Asset class.

In CakePHP 2 assets are handled in Html::assetUrl which interacts with Html::webroot, Html::assetTimestamp and also AssetDispatcher::_getAssetFile which duplicates logic from Html::assetTimestamp.

An Asset class would accept a route or url for an asset and offers primarily Asset::url (with or without timestamp) and Asset::path.

Any opinions?

mark_story

unread,
Nov 13, 2013, 10:49:12 AM11/13/13
to cakeph...@googlegroups.com
I think a separate class would be useful. I don't think you could call it asset, as that might collide with userland code. Usually we prefix with Cake in these situations. Lastly, I would not make it a static class. Instances are easier to test mock and swap out if necessary.
Reply all
Reply to author
Forward
0 new messages