Commit Graph

36048 Commits

Author SHA1 Message Date
Mathieu Piot
d723756331 Fix some mistakes 2018-03-23 15:53:02 +01:00
Mathieu Piot
c74e0dc2da Use spaceless balises in Twig templates 2018-03-23 15:53:02 +01:00
Mathieu Piot
8b937ff43f Try without try/catch 2018-03-23 15:53:02 +01:00
Mathieu Piot
32bf1f68ad Test the renderHelp method in all Tests about help to skip them if necessary. 2018-03-23 15:53:02 +01:00
Mathieu Piot
437b77e81a Skip renderHelp test as skipped if not override 2018-03-23 15:53:02 +01:00
Mathieu Piot
d84be700b2 Update composer files 2018-03-23 15:53:02 +01:00
Mathieu Piot
075fcfd07c [FrameworkBundle] Add widgetAtt to formTable/form_row 2018-03-23 15:53:02 +01:00
Mathieu Piot
f1d13a860c Fix Fabpot.io 2018-03-23 15:53:02 +01:00
Nyholm
69ded67643 Added form_help on horizontal design and removed special variable 2018-03-23 15:53:02 +01:00
Mathieu Piot
fd53bc579a Enable aria-described in row for all Templates 2018-03-23 15:53:02 +01:00
Mathieu Piot
98065d38b5 fabpot.io fix 2018-03-23 15:53:02 +01:00
Mathieu Piot
edb95f8e44 Use array long syntax 2018-03-23 15:53:02 +01:00
Mathieu Piot
aada72c5d4 Set help option on nul as default 2018-03-23 15:53:02 +01:00
Mathieu Piot
f948147e38 Rename help id (snake_case) 2018-03-23 15:53:02 +01:00
Mathieu Piot
77fa3178bd Fix Test 2018-03-23 15:53:02 +01:00
Mathieu Piot
30deaa9b28 PSR fix 2018-03-23 15:53:02 +01:00
Mathieu Piot
bf4d08c5ae Add aria-describedBy on input 2018-03-23 15:53:02 +01:00
Mathieu Piot
1f3a15e33b Rename id 2018-03-23 15:53:02 +01:00
Mathieu Piot
058489d7df Add an id to the help 2018-03-23 15:53:02 +01:00
Mathieu Piot
6ea7a2054b Remove vars option from form_help 2018-03-23 15:53:02 +01:00
Mathieu Piot
ba798dfdf4 FrameworkBundle Tests 2018-03-23 15:53:02 +01:00
Mathieu Piot
4f2581d7da Use array long syntax 2018-03-23 15:53:02 +01:00
Mathieu Piot
f15bc79df1 Fix coding standards 2018-03-23 15:53:02 +01:00
Mathieu Piot
c934e496d2 Add test without help set 2018-03-23 15:53:02 +01:00
Mathieu Piot
8094804522 Add Tests 2018-03-23 15:53:02 +01:00
Mathieu Piot
067c681580 Template for table, Foundation and Bootstrap 3 2018-03-23 15:53:02 +01:00
Mathieu Piot
d3e3e492df Fix: check translation domain 2018-03-23 15:53:02 +01:00
Mathieu Piot
2c2c04549f Adapt existant tests 2018-03-23 15:53:02 +01:00
Mathieu Piot
831693ad45 Add trans filter 2018-03-23 15:53:01 +01:00
Mathieu Piot
e311838aed Remove raw filter for help 2018-03-23 15:53:01 +01:00
Mathieu Piot
8b97c1b516 Use a shortcut to acces help var in Twig template 2018-03-23 15:53:01 +01:00
Mathieu Piot
1b89f9d9dd Add a template fot div_layout 2018-03-23 15:53:01 +01:00
Mathieu Piot
c8914f591e Add a data_help method in Form 2018-03-23 15:53:01 +01:00
Grégoire Pineau
d5a55a50e4 feature #26651 [Workflow] Added a TransitionException (andrewtch, lyrixx)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[Workflow] Added a TransitionException

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26587 #26581
| License       | MIT
| Doc PR        |

---

Note for reviewer: `NotEnabledTransitionException` and `UndefinedTransitionException` were not released. So this is not a BC Break.

Commits
-------

838548c Finished implementation of TransitionException
9fa4f79 implemented TransitionException to be thrown instead of Logic exception
2018-03-23 11:57:29 +01:00
Grégoire Pineau
838548c54f Finished implementation of TransitionException 2018-03-23 11:28:40 +01:00
Andrew Tch
9fa4f794b0 implemented TransitionException to be thrown instead of Logic exception 2018-03-23 11:17:24 +01:00
Fabien Potencier
4bbdf06c10 feature #23831 [VarDumper] Introduce a new way to collect dumps through a server dumper (ogizanagi, nicolas-grekas)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[VarDumper] Introduce a new way to collect dumps through a server dumper

| Q             | A
| ------------- | ---
| Branch?       | 4.1 <!-- see comment below -->
| Bug fix?      | no
| New feature?  | yes <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #22987 <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | todo <!--highly recommended for new features-->

Could also be interesting as alternate solution for #23442.

Inspired by the [`ServerLogHandler`](https://github.com/symfony/symfony/pull/21080) and @nicolas-grekas's [comment](https://github.com/symfony/symfony/pull/22987#issuecomment-305791102) in #22987.

---

## Description

This PR introduces a new `server:dump` command available in the `VarDumper` component.
Conjointly with a new `ServerDumper` data dumper, it allows to send serialized `Data` clones to a single centralized server, in charge of dumping them on CLI output, or in an file in HTML format.

## Showcase

### HTTP calls

For instance, when working on an API and dumping something, you might end up with a mix of your response and the CLI dumped version of the data you asked:

```php
class HelloController extends AbstractController
{
    /**
     * @Route("/hello")
     */
    public function hello(Request $request, UserInterface $user)
    {
        dump($request->attributes, $user);

        return JsonResponse::create([
            'status' => 'OK',
            'message' => "Hello {$user->getUsername()}"
        ]);
    }
}
```

<img width="732" alt="screenshot 2017-08-08 a 16 44 24" src="https://user-images.githubusercontent.com/2211145/29077731-0b2152d6-7c59-11e7-99dd-2d060a906d48.PNG">

You might even get the HTML dump version [under some conditions](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php#L146-L157).

Dumping to a server allows collecting dumps in a separate place:

<!--![server-dumper-http-to-cli-output](https://user-images.githubusercontent.com/2211145/29077977-8ace19ce-7c59-11e7-998e-ee9c49e67958.gif)-->

![server-dump-http-to-cli](https://user-images.githubusercontent.com/2211145/29226044-dcc95f12-7ed0-11e7-8343-40aeb7b18dd5.gif)

~⚠️ By swallowing the previous dumpers output, the dump data collector is not active when running the dump server. Disable swallowing if you want both.~ ➜ Dumps are still collected in the profiler thanks to f24712effc9fab1163c0053e2a0a0d5cc4f6473e

### CLI calls

The best probably is (to me) that you can also debug CLI applications...

![server-dump-cli](https://user-images.githubusercontent.com/2211145/29225951-84e29098-7ed0-11e7-8067-abaa9c50d169.gif)

<!--![server-dumper-cli-to-cli-output](https://user-images.githubusercontent.com/2211145/29078261-1eb950ea-7c5a-11e7-94ee-aa3ae3bf7fb0.gif)-->

...and get HTML formatted dumps:

![server-dumper-cli-to-html-output](https://user-images.githubusercontent.com/2211145/30784609-d7dc19b8-a158-11e7-9b11-88ae819cfcca.gif)

<!--![server-dump-cli-to-html](https://user-images.githubusercontent.com/2211145/29225866-2b5675e4-7ed0-11e7-98eb-339611bd94a7.gif)-->

<!--![server-dumper-cli-to-html-output](https://user-images.githubusercontent.com/2211145/29078247-17e33e5c-7c5a-11e7-94f7-47de6774e0e8.gif)-->

hence, benefit from all the features of this format (collapse, search, ...)

### HTML output at a glance

<img width="831" alt="screenshot 2017-08-11 a 19 28 25" src="https://user-images.githubusercontent.com/2211145/29225513-eae349f2-7ece-11e7-9861-8cda9e80ba7f.PNG">

The HTML output benefits from all the `HtmlDumper` features and contains extra informations about the context (sources, requests, command line, ...). It doesn't aim to replace the profiler for HTTP calls with the framework, but is really handy for CLI apps or by wiring it in your own web app, out of the framework usage.

### CLI output at a glance

<img width="829" alt="screenshot 2017-08-11 a 19 52 57" src="https://user-images.githubusercontent.com/2211145/29225482-c24afe18-7ece-11e7-8e83-d019b0d8303e.PNG">

## Usage within the framework

### Config

For instance, in your `config_dev.yml`:

```yml
#config_dev.yml
debug:
    server_dump: true
```

or in your `config.yml`:

```yml
#config.yml
debug:
    server_dump: '%kernel.debug%'
```

~~The configuration also allows to set a `host` option, but there is already a sensible default value (`tcp://0.0.0.0:9912`) so you don't have to deal with it.~~ Since b002175, in case you want to change the default host value used, simply use the `VAR_DUMPER_SERVER` env var.

When the server is running, all dumps are collected by the server and previous dumpers ones are "swallowed" ~~by default. If you want both to collect dumps on the server AND keep previous dumpers on regular outputs, you can disable swallowing:~~

<!--
```yml
debug:
    server_dump:
        swallow: false
```
-->

When the server isn't running or in case of failure to send the data clones to the server, the server dumper will delegates to the configured wrapped dumper, so dumps are displayed and collected as usual.

### Running the server

```bash
bin/console server:dump [--format=cli|html]
```

#### Options

- ~~The `output` option defaults to `null` which will display dumps on CLI. It accepts a file path in which dumps will be collected in HTML format.~~
- The `format` option allows to switch format to use. For instance, use the `html` format and redirect the output to a file in order to open it in your browser and inspect dumps in HTML format.
- ~~The default `host` value is the same as the one configured under the `debug.server_dump.host` config option, so you don't have to deal with it in most cases.~~
    Since b002175, in case you want to change the default host value used, simply use the `VAR_DUMPER_SERVER` env var:

    ```bash
    VAR_DUMPER_SERVER=0.0.0.0:9204 bin/console server:dump
    ```

## Manual wiring

If you want to wire it yourself in your own project or using it to inspect dumps as html before the kernel is even boot for instance:

```php
$host = 'tcp://0.0.0.0:9912'; // use null to read from the VAR_DUMPER_SERVER env var
$cloner = new VarCloner();
$dumper = new ServerDumper($host, new CliDumper());

VarDumper::setHandler(function ($var) use ($dumper, $cloner) {
    $dumper->dump($cloner->cloneVar($var));
});
```

## Create your own server app

The component already provides a default server app by means of the `ServerDumpCommand`, but
 you could also build your own by using the `DumpServer`:

```php
$host = 'tcp://0.0.0.0:9912'; // use null to read from the VAR_DUMPER_SERVER env var

$server = new DumpServer($host);

$server->start();

$server->listen(function (Data $data, array $context, $clientId) {
    // do something
});
```

Commits
-------

138dad6440 [VarDumper] Some tweaks after Nicolas' commit & ServerDumperPlaceholderCommand
088c52ed70 [VarDumper] Review config to use debug.dump_destination & tweak data collector
3db14045d4 [VarDumper] Introduce a new way to collect dumps through a server dumper
2018-03-23 10:18:50 +01:00
Maxime Steinhausser
138dad6440 [VarDumper] Some tweaks after Nicolas' commit & ServerDumperPlaceholderCommand 2018-03-23 10:12:13 +01:00
Nicolas Grekas
088c52ed70 [VarDumper] Review config to use debug.dump_destination & tweak data collector
(cherry picked from commit 602b9a8)
2018-03-23 10:11:10 +01:00
Maxime Steinhausser
3db14045d4 [VarDumper] Introduce a new way to collect dumps through a server dumper 2018-03-23 10:11:09 +01:00
Fabien Potencier
54305d669e feature #26220 [HttpFoundation] Use parse_str() for query strings normalization (nicolas-grekas)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[HttpFoundation] Use parse_str() for query strings normalization

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Follow up of #26214 and #26202

The current normalization logic is both too loose and too broad: it changes the order of recursive data structures, while not normalizing keys.
Since the normalization logic varies by query string parser, I'd like to propose a logic that exactly matches the native PHP one, which is exposed to userland via `parse_str()`. Using this, we accurately remove all useless information, while preserving all the meaningful one.

(The change in `overrideGlobals()` is a bug fix to me btw, the current logic breaks the interpretation of legitimate query strings.)

Commits
-------

513353644b [HttpFoundation] Use parse_str() for query strings normalization
2018-03-23 09:03:49 +01:00
Fabien Potencier
e157dedc6a feature #24411 [Messenger] Add a new Messenger component (sroze)
This PR was squashed before being merged into the 4.1-dev branch (closes #24411).

Discussion
----------

[Messenger] Add a new Messenger component

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #24326
| License       | MIT
| Doc PR        | symfony/symfony-docs#9437

As discussed in #24326. This PR is to help going forward with the discussions of having a Message component.

# Resources

| What | Where
| --- | ---
| Documentation | [In the PR](https://github.com/sroze/symfony/blob/add-message-component/src/Symfony/Component/Message/README.md)
| Demo | [In `sroze/symfony-demo:message-component-demo`](https://github.com/sroze/symfony-demo/compare/message-component-demo)
| [php-enqueue](https://github.com/php-enqueue/enqueue-dev) adapter | 1. Source: [In `sroze/enqueue-bridge`](https://github.com/sroze/enqueue-bridge) _(to be moved as `symfony/enqueue-bridge` I guess)_<br/>2. Demo: [In `sroze/symfony-demo:message-component-demo-with-enqueue`](https://github.com/sroze/symfony-demo/compare/message-component-demo...sroze:message-component-demo-with-enqueue)
| [Swarrot](https://github.com/swarrot/swarrot) adapter | **Outdated adapter, waiting for stabilization** 1. Source: [In `sroze/swarrot-bridge`](https://github.com/sroze/swarrot-bridge) _(to be moved as `symfony/swarrot-bridge` I guess)_<br/>2. Demo: [In `sroze/symfony-demo:message-component-demo-with-swarrot`](https://github.com/sroze/symfony-demo/compare/message-component-demo...sroze:message-component-demo-with-swarrot)
| [HTTP](https://github.com/sroze/message-http-adapter) adapter | **Outdated adapter, waiting for stabilization** 1. Source: [In `sroze/message-http-adapter`](https://github.com/sroze/message-http-adapter) <br/>2. Demo: [In `sroze/symfony-demo:message-component-demo-with-http-adapter`](https://github.com/sroze/symfony-demo/compare/message-component-demo...sroze:message-component-demo-with-http-adapter)
| Web profiler integration | _In the pull-request_

# Important points

1. **Tests are not in the PR as they were written in PhpSpec & Behat.** If we decide to go forward with this approach, I'll translate them to PHPUnit.
2. The aim is not to solve all the message/queuing problems but provide a good, simple and extensible message bus for developers.
3. The communication with the actual AMQP/API brokers is down to the adapters for now. Not sure if we need to ship some by default or not 🤔

I guess that this would replace #23842 & #23315.

# Changes from the proposals

Based on the comments, a few changes have been made from the proposal.

1. `MessageProducer`s have been renamed to `MessageSender`s
2. `MessageConsumer`s have been renamed to `MessageReceiver`s

Commits
-------

c9cfda990b [Messenger] Add a new Messenger component
2018-03-23 09:01:57 +01:00
Samuel ROZE
c9cfda990b [Messenger] Add a new Messenger component 2018-03-23 09:01:52 +01:00
Fabien Potencier
acf49e9d85 feature #22150 [Serializer] Added a ConstraintViolationListNormalizer (lyrixx)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[Serializer] Added a ConstraintViolationListNormalizer

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #11309
| License       | MIT
| Doc PR        | -

---

It seems logical to me that Symfony is able to serialise natively some very common Symfony data structure. (and requested by @nicolas-grekas & @javiereguiluz )

Usage example (from symfony/symfony-demo):

```php
    /**
     * @Route("", name="api_blog_new")
     * @Method("POST")
     * @Security("is_granted('ROLE_ADMIN')")
     */
    public function newAction(Request $request)
    {
        $data = $request->getContent();

        $post = $this->get('serializer')->deserialize($data, Post::class, 'json', ['groups' => ['post_write']]);

        $post->setAuthor($this->getUser());

        $violations = $this->get('validator')->validate($post);

        $post->setSlug($this->get('slugger')->slugify($post->getTitle()));

        if (count($violations) > 0) {
            $repr = $this->get('serializer')->serialize($violations, 'json');

            return JsonResponse::fromJsonString($repr, 400);
        }

        $this->getDoctrine()->getManager()->persist($post);
        $this->getDoctrine()->getManager()->flush();

        $repr = $this->get('serializer')->serialize($post, 'json', ['groups' => ['post_read']]);

        return JsonResponse::fromJsonString($repr);
    }
```

Commits
-------

2a35d09f53 [Serializer] Added a ConstraintViolationListNormalizer
2018-03-23 08:59:18 +01:00
Robin Chalas
7eae6afe49 feature #26639 [SecurityBundle] Added an alias from RoleHierarchyInterface to security.role_hierarchy (lyrixx)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[SecurityBundle] Added an alias from RoleHierarchyInterface to security.role_hierarchy

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | I don't know
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

It's needed for autowirering

---

Note: I'm not sure if this is a bug fix or a new feature.

Commits
-------

886b8a6 [SecurityBundle] Added an alias from RoleHierarchyInterface to security.role_hierarchy
2018-03-23 02:03:39 +01:00
Grégoire Pineau
886b8a6e29 [SecurityBundle] Added an alias from RoleHierarchyInterface to security.role_hierarchy 2018-03-22 17:50:26 +01:00
Nicolas Grekas
61da48799c feature #26636 [DI] deprecate TypedReference::canBeAutoregistered() and getRequiringClass() (nicolas-grekas)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[DI] deprecate TypedReference::canBeAutoregistered() and getRequiringClass()

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

~Needs #26634~

Commits
-------

95fd81b [DI] deprecate TypedReference::canBeAutoregistered() and getRequiringClass()
2018-03-22 15:56:57 +01:00
Nicolas Grekas
95fd81b5d8 [DI] deprecate TypedReference::canBeAutoregistered() and getRequiringClass() 2018-03-22 15:55:20 +01:00
Nicolas Grekas
9131bd1c4b Merge branch '4.0'
* 4.0:
  [DI] Dont tell about autoregistration in strict autowiring mode
  [DI] Cleanup remainings from autoregistration
  [Process] Remove a useless cast
  [PHPunit] suite variable should be used
2018-03-22 14:45:58 +01:00
Nicolas Grekas
0c8ca6acdb Merge branch '3.4' into 4.0
* 3.4:
  [DI] Dont tell about autoregistration in strict autowiring mode
  [PHPunit] suite variable should be used
2018-03-22 14:42:36 +01:00