-
Notifications
You must be signed in to change notification settings - Fork 261
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
Expose routing options to javascript routes #238
base: master
Are you sure you want to change the base?
Conversation
Only route options in the exposed_options array are exposed if the new config parameter (fos_js_routing.expose_options) is true.
Is there anything i can do to get this merged? @willdurand |
Options are meant to configure the route generator and the route matcher only. They are not meant to retrieve data at runtime about the route (doing it in PHP requires using APIs which are not meant for performance, and will be very slow as it will not cache routing info). So what is the use case for this feature ? |
We are using this bundle to expose our routes to the angular frontend, so it can create URLs on their own. The frontend needs additional information if a specific route is part of the angular single page application or if its a normal route to a page where the backend renders the page. Our approach was to configure this info (single page or not) together with the routing configuration, so we have only one place where the routes are defined and not an additional place which tells if a route is single-page or not. This addional option is exposed together with the other routing configuration on dump of the routes to the JS file. Is a call like 9645296#diff-43d8db7df15e660b384d40030b881e89R123 really a performance issue? |
Add typescript configuration to expose routes |
I'm sorry @Lawrancecool, but I don't understand what you say. Could you explain it a little more in detail? |
Add typescript configuration to expose routes: How we will do in Typescript??? can you Help |
Sorry. I'm not able to help you. I'm not using Typescript or Angular2. In fact I just wrote this backend stuff for our frontend developer. |
thanks i already got solution |
I haven't tried testing this PR, but I think we have a very similar use case that I wanted to explain to see if this helps make the case for adding such a feature. We're migrating parts of a large application to React + Inertia.js, and we wrote a React component that handles links to routes using the route name and any parameters the route requires. Inside this component we have a list of "Inertia powered routes" so the component knows if it should render a standard It's not ideal to maintain this list of "Inertia powered routes" in this component, as it's easy for a developer to forget to add the route to the list when a route is migrated to Inertia, or if a route's name is changed, or removed entirely. We thought it would be nice if in the Route's options (via the I don't understand the performance implications that were mentioned earlier, as, in this case at least, this would only be something that would be called when the JSON file is built (for us that's done during the app's build process, but I'll admit, I don't know how other people are using this library). And unless I'm misunderstanding something, the values here in this "options" property should be static (defined in the Route's annotation, or in the routes.yaml file). |
I took @schmaun's branch and merged in the latest Docs here: https://github.com/diablomedia/FOSJsRoutingBundle/blob/expose-options/Resources/doc/usage.rst |
We needed some options available in our angular application together with the routes configuration. Because we only want one place where routes and their options are defined, we need a way to expose options from the symfony routing definition.
I added a paramater (fos_js_routing.expose_options) to enable this feature. If enabled any exposed_options inside the options of a route are exposed to the javascript routes as a "options" property.
Also I changed the URL from where closure is loaded to githubusercontent.com to get a stable build.
All tests passed: https://travis-ci.org/MyHammer/FOSJsRoutingBundle/builds/114553462