Skip to content

Cookbook entry: Asset - Custom Version Strategy #5489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

teohhanhui
Copy link
Contributor

Q A
Doc fix? no
New docs? yes
Applies to 2.7+
Fixed tickets #4982

@teohhanhui teohhanhui force-pushed the cookbook_asset_custom_version_strategy branch from 94bd6ba to b5f5b71 Compare July 5, 2015 21:27
@teohhanhui teohhanhui changed the title Cookbook entry: Asset - custom version strategy Cookbook entry: Asset - Custom Version Strategy Jul 5, 2015
@teohhanhui teohhanhui force-pushed the cookbook_asset_custom_version_strategy branch 2 times, most recently from 1c48a83 to 79564d2 Compare July 5, 2015 22:11
Default Package
---------------

The default package is the `''` package. It is used when you do not specify
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an empty string. I should make that clearer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@OskarStark
Copy link
Contributor

great job @teohhanhui

@teohhanhui teohhanhui force-pushed the cookbook_asset_custom_version_strategy branch from 79564d2 to 4daa0f9 Compare July 17, 2015 06:08
How to use a Custom Version Strategy for Assets
===============================================

Out of the box, Symfony exposes configuration options which allow you to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to reword this paragraph. Instead of saying: "Symfony has some options to tweak things" ... we could say something like: "Symfony uses by default the XXX asset versioning strategy. Its behavior can be controlled with the xxx and yyy configuration options".

@javiereguiluz
Copy link
Member

@teohhanhui thanks for writing this article. I like it a lot because I didn't know how to define your own asset versioning strategy 👍

@teohhanhui teohhanhui force-pushed the cookbook_asset_custom_version_strategy branch from 4daa0f9 to 8d71390 Compare July 17, 2015 09:12
@teohhanhui
Copy link
Contributor Author

Anything else that you need me to change?

override the version strategy used by the default package, it is necessary
to add a compiler pass.

This example shows how to integrate with `gulp-buster`_. Note: busters.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could put this "Note" in a note block

@teohhanhui teohhanhui force-pushed the cookbook_asset_custom_version_strategy branch 3 times, most recently from cb1c157 to 254ddac Compare July 23, 2015 14:36
.. index::
single: Asset; Custom Version Strategy

How to use a Custom Version Strategy for Assets
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"use" must be capitalised

@teohhanhui teohhanhui force-pushed the cookbook_asset_custom_version_strategy branch from 254ddac to 2f8f74b Compare July 25, 2015 09:55
>
<services>
<service id="app.assets.buster_version_strategy" class="AppBundle\Asset\VersionStrategy\BusterVersionStrategy" public="false">
<argument type="collection">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong. Your XML config is passing a single argument to BusterVersionStrategy which is an array with 2 elements, which does not match at all the config in other formats

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm no sorry. It does match them. I looked at it too fast. However, I don't think passing an array of option is worth it. Just configure things with normal arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since PHP doesn't have named arguments, it's rather unfortunate that things become unrecognizable soon when you no longer know what's what.

@teohhanhui teohhanhui force-pushed the cookbook_asset_custom_version_strategy branch from 2f8f74b to b770f79 Compare August 1, 2015 13:18
@teohhanhui
Copy link
Contributor Author

Are we good yet?

@OskarStark
Copy link
Contributor

i would say: yes

@xabbuh
Copy link
Member

xabbuh commented Aug 17, 2015

Wow, I really like this article! 👍 However, I think we should just move some contents around to show a more straight-forward implementation. What I have in mind to have short introduction which list the required steps:

  • implement the version strategy
  • create the compiler pass
  • register the compiler

I also think we should not focus on the default package. We can make the compiler pass generic and pass the package name as an argument to the constructor (we could just use the default package name in our example and add a sidebar which adds a short explanation about packages in general and the default package here). What do you think?

@teohhanhui
Copy link
Contributor Author

@xabbuh

add a sidebar which adds a short explanation about packages in general and the default package here

Sidebar?

@xabbuh
Copy link
Member

xabbuh commented Aug 18, 2015

@teohhanhui You can use a sidebar directive like this:

.. sidebar:: sidebar title

    sidebar contents

Technically, it will not be rendered as a sidebar on symfony.com, but more like an additional note.

@xabbuh
Copy link
Member

xabbuh commented May 21, 2016

@teohhanhui Are you able to finish this one? :)

return $versionized;
}

private function loadManifest(array $options)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$options is never used, should be removed.

But great work on this cookbook article! Is exactly what I was looking for.

@teohhanhui
Copy link
Contributor Author

@xabbuh Will try...

@javiereguiluz
Copy link
Member

Closing it in favor of #7141, which finishes this great article. Thanks @teohhanhui for your work. I've reused your original commits, so you'll get full credit for your work.

xabbuh added a commit that referenced this pull request Dec 12, 2016
…teohhanhui, javiereguiluz)

This PR was merged into the 2.7 branch.

Discussion
----------

Added "How to Use a Custom Version Strategy for Assets"

This PR finishes the great work made by @teohhanhui in #5489.

Commits
-------

1399967 Fixed a label name
981e82d Misc fixes
a02f3b3 Added the version_strategy option to the config reference
2830ba0 Added the missing doc label
482fda5 Minor rewords and fixes
f038483 Removed an unneeded change
ab8fa54 Fixed a rebase error
c59cff6 Moved the article to its new location
5971ce0 Removed an unneeded file
40dff64 Minor updates to the doc and service config
80d0ca2 Simplified the intro
4f530d8 Cookbook entry: Asset - Custom Version Strategy
xabbuh added a commit that referenced this pull request Dec 14, 2016
… (xabbuh)

This PR was merged into the 3.1 branch.

Discussion
----------

Added "How to Use a Custom Version Strategy for Assets"

Another attempt to finish @teohhanhui's great work from #5489.

This will fix #6205.

Commits
-------

d3308be Added "How to Use a Custom Version Strategy for Assets"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants