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/tests/Symfony/Tests/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 [Config] Improve handling of PrototypedArrayNode defaults 2012-02-20 23:07:03 +01:00
Console restore previous testing style with static fixtures for console 2012-03-21 05:32:53 +01:00
CssSelector [CssSelector] fixed CssSelector::toXPath() when the CSS selector is an empty string 2012-03-11 10:18:25 +01:00
DependencyInjection merged 2.0 2012-03-08 19:29:37 +01:00
DomCrawler fixed CS, phpdoc, removed unused use statements 2012-01-28 18:02:36 +01:00
EventDispatcher [EventDispatcher] Add fluid interface on dispatch() 2012-03-10 09:55:57 +05:45
Finder [Finder] added a convenience method Finder::create() 2011-06-14 14:18:24 +02:00
Form merged 2.0 2012-03-15 15:47:03 +01:00
HttpFoundation remove callback from constructor and create method 2012-03-21 22:40:39 +01:00
HttpKernel [HttpKernel] Fix MongoDbProfilerStorageTest 2012-03-20 17:56:45 +01:00
Locale [WIP][Locale] StubIntlDateFormatter::parse was throwing exception instead of returning Boolean false like intl implementation 2012-02-14 01:35:14 -02:00
Process Restore bypass_shell by default with windows compat 2012-02-22 14:19:04 +01:00
Routing [Routing] Cleanup 2012-03-20 09:12:35 +01:00
Security merged branch jmikola/logout-csrf (PR #3007) 2012-03-05 16:12:24 +01:00
Serializer merged 2.0 2012-02-26 14:24:21 +01:00
Templating [Templating] fixed 'scheme://' not detected as absolute path 2011-12-08 15:42:21 +01:00
Translation fixed previous merge 2012-03-21 22:35:06 +01:00
Validator Improved feedback for Upload Validator to cover all PHP error states. 2012-03-19 14:37:25 +01:00
Yaml merged 2.0 2011-12-18 14:48:17 +01:00