This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component
Fabien Potencier 26c9cb787e merged branch havvg/feature/jsonp-response (PR #3639)
Commits
-------

4a43453 remove callback from constructor and create method
601b87c add basic validation of callback name
266f76d rename jsonp to callback, defaults to null
38b79a7 add data and callback setter to JsonResponse
6788224 add JSONP support to JsonResponse

Discussion
----------

add JSONP support to JsonResponse

---------------------------------------------------------------------------

by schmittjoh at 2012-03-19T17:56:24Z

I think a ``setCallback()`` method would be more expressive, and easier to use:

```php
<?php

return JsonResponse::create($myData)->setCallback('foo');
// vs
return new JsonResponse($myData, 200, array(), 'foo');
```

What do you think?

---------------------------------------------------------------------------

by havvg at 2012-03-19T18:07:38Z

Looks good to me, I'll add it.

---------------------------------------------------------------------------

by dlsniper at 2012-03-19T19:38:45Z

+1 for this one :)

---------------------------------------------------------------------------

by vicb at 2012-03-19T23:09:50Z

Sorry for nitpicking but what about:

* some validation on the function name ?
* renamming `jsonp` -> `callback` ?

---------------------------------------------------------------------------

by havvg at 2012-03-20T09:16:32Z

@vicb What do you mean with "some validation on the function name"? I can't follow you there.

---------------------------------------------------------------------------

by vicb at 2012-03-20T09:22:49Z

I mean a valid JS function name

---------------------------------------------------------------------------

by havvg at 2012-03-20T09:34:59Z

Ah I see, I searched for it, and ended up with those results:

* The most complete: http://stackoverflow.com/questions/2008279/validate-a-javascript-function-name#answer-9392578
* and a less accurate one: http://www.geekality.net/2011/08/03/valid-javascript-identifier/

I'm not sure whether to put this into the `JsonResponse` itself, or to add somewhere else (where, if so?).

---------------------------------------------------------------------------

by vicb at 2012-03-20T09:45:20Z

I would go for a regexp only (ignoring reserved words); The idea would be not to use this to run arbitrary JS code.

---------------------------------------------------------------------------

by fabpot at 2012-03-21T21:33:36Z

Now that you have added the `setCallback` method, I would remove the constructor argument as it makes the signature quite long. As we have the `create` method anyway, it's more explicit and clearer to use the `setCallback` .

---------------------------------------------------------------------------

by havvg at 2012-03-21T21:37:51Z

So remove the callback argument from both, the constructor and the `create` method or only from the constructor?

---------------------------------------------------------------------------

by havvg at 2012-03-21T21:38:30Z

Ehr.. never mind :-)
2012-03-22 00:10:35 +01:00
..
BrowserKit merged 2.0 2012-03-11 18:00:10 +01:00
ClassLoader [ClassLoader] Fixed version compare 2012-03-09 08:17:46 +01:00
Config merged 2.0 2012-03-15 15:47:03 +01:00
Console fix Command:asXml to use processed help 2012-03-21 05:32:51 +01:00
CssSelector merged 2.0 2012-03-11 18:00:10 +01:00
DependencyInjection merged 2.0 2012-03-08 19:29:37 +01:00
DomCrawler Removed version field 2012-02-27 09:59:20 +01:00
EventDispatcher fixed CS 2012-03-11 18:00:25 +01:00
Filesystem Removed version field 2012-02-27 09:59:20 +01:00
Finder merged branch Seldaek/composer_alias (PR #3457) 2012-02-27 10:07:31 +01:00
Form [Form] Fix min/max length guessing for numeric types (fix #3091) 2012-03-19 23:57:21 +01:00
HttpFoundation remove callback from constructor and create method 2012-03-21 22:40:39 +01:00
HttpKernel unused variable removed 2012-03-21 22:15:47 +01:00
Locale merged 2.0 2012-03-11 18:00:10 +01:00
Process merged 2.0 2012-03-08 19:29:37 +01:00
Routing [Routing] Updated Router::match and Router::generate documentation 2012-03-01 20:27:36 +01:00
Security [SecurityBundle] Allow switching to the user that is already impersonated (fix #2554) 2012-03-15 01:50:14 -07:00
Serializer merged branch Seldaek/composer_alias (PR #3457) 2012-02-27 10:07:31 +01:00
Templating Removed version field 2012-02-27 09:59:20 +01:00
Translation [Translation] Ignore xliff entries with no "target" node 2012-03-21 14:55:53 +01:00
Validator Fixing typo. 2012-03-19 23:29:43 +01:00
Yaml Removed version field 2012-02-27 09:59:20 +01:00