File tree Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Original file line number Diff line number Diff line change @@ -461,12 +461,30 @@ private function changeValueInYaml($value)
461461 // empty space between key & value
462462 $ newYamlValue = ' ' .$ newYamlValue ;
463463 }
464+
465+ $ newPosition = $ this ->currentPosition + \strlen ($ newYamlValue );
466+ $ isNextContentComment = $ this ->isPreviousLineComment ($ newPosition );
467+ if ($ isNextContentComment ) {
468+ $ newPosition ++;
469+ }
470+
464471 $ newContents = substr ($ this ->contents , 0 , $ this ->currentPosition )
465472 .$ newYamlValue
473+ /*
474+ * If the next line is a comment, this means we probably had
475+ * a structure that looks like this:
476+ * access_control:
477+ * # - { path: ^/admin, roles: ROLE_ADMIN }
478+ *
479+ * In this odd case, we need to know that the next line
480+ * is a comment, so we can add an extra line break.
481+ * Otherwise, the result is something like:
482+ * access_control:
483+ * - { path: /foo, roles: ROLE_USER } # - { path: ^/admin, roles: ROLE_ADMIN }
484+ */
485+ .($ isNextContentComment ? "\n" : '' )
466486 .substr ($ this ->contents , $ endValuePosition );
467487
468- $ newPosition = $ this ->currentPosition + \strlen ($ newYamlValue );
469-
470488 $ newData = $ this ->currentData ;
471489 $ newData = $ this ->setValueAtCurrentPath ($ value , $ newData );
472490
Original file line number Diff line number Diff line change 1+ # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
2+ security:
3+ access_control:
4+ ===
5+ $data['security']['access_control'] = [];
6+ $data['security']['access_control'][] = ['path' => '^/login$', 'roles' => 'IS_AUTHENTICATED_ANONYMOUSLY'];
7+ ===
8+ # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
9+ security:
10+ access_control:
11+ -
12+ path: ^/login$
13+ roles: IS_AUTHENTICATED_ANONYMOUSLY
Original file line number Diff line number Diff line change 1+ # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
2+ security:
3+ access_control:
4+ # - { path: ^/admin, roles: ROLE_ADMIN }
5+ # - { path: ^/profile, roles: ROLE_USER }
6+ ===
7+ $data['security']['access_control'] = [];
8+ $data['security']['access_control'][] = ['path' => '^/login$', 'roles' => 'IS_AUTHENTICATED_ANONYMOUSLY'];
9+ ===
10+ # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
11+ security:
12+ access_control:
13+ -
14+ path: ^/login$
15+ roles: IS_AUTHENTICATED_ANONYMOUSLY
16+ # - { path: ^/admin, roles: ROLE_ADMIN }
17+ # - { path: ^/profile, roles: ROLE_USER }
You can’t perform that action at this time.
0 commit comments