From e25f44a6aa8b81863b0dd8756bdb1dbf3b0bdbbd Mon Sep 17 00:00:00 2001 From: SonataCI Date: Fri, 13 May 2016 18:26:00 +0000 Subject: [PATCH 1/7] DevKit updates --- .editorconfig | 23 +++++ .github/ISSUE_TEMPLATE.md | 23 +++++ .php_cs | 39 ++++--- .styleci.yml | 22 ++++ .travis.yml | 112 +++++++++++--------- CONTRIBUTING.md | 210 +++++++++++++++++++++++++++++++++----- LICENSE | 21 ++++ Makefile | 13 ++- README.md | 36 +++---- 9 files changed, 386 insertions(+), 113 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .styleci.yml create mode 100644 LICENSE diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..589cb89dd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,23 @@ +root = true + +[*] +end_of_line = lf +indent_style = space +charset = utf-8 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{yml,twig,php}] +indent_size = 4 + +[*.{js,json,scss,css}] +indent_size = 2 + +[.travis-ci.yml] +indent_size = 2 + +[composer.json] +indent_size = 4 + +[Makefile] +indent_style = tab diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..87c36a44f --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,23 @@ +Delete this sentence after you read the "Issues" paragraph from the +"guidelines for contributing" link above. + +If you are reporting a bug, please try to fill in the following, otherwise +remove it along with this sentence. + +| Question | Answer +|----------------|------------------------------- +| Bundle version | composer show sonata-project/* +| Symfony version| composer show symfony/* +| php version | php --version + +# Error message + +``` +Error message goes here +``` + +# Steps to reproduce + +# Expected results + +# Actual results diff --git a/.php_cs b/.php_cs index d0d370fa8..4f1d17dd8 100644 --- a/.php_cs +++ b/.php_cs @@ -1,20 +1,29 @@ in(array(__DIR__)) - ->exclude(array('Tests/Fixtures')) -; +/* + * DO NOT EDIT THIS FILE! + * + * It's auto-generated by sonata-project/dev-kit package. + * + * Package `sllh/php-cs-fixer-styleci-bridge` is required to get it working. + */ + +require_once __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php'; + +use SLLH\StyleCIBridge\ConfigBridge; +use Symfony\CS\Fixer\Contrib\HeaderCommentFixer; + +$header = << + +For the full copyright and license information, please view the LICENSE +file that was distributed with this source code. +EOF; + +HeaderCommentFixer::setHeader($header); -return Symfony\CS\Config\Config::create() - ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) - ->fixers(array( - '-unalign_double_arrow', - '-unalign_equals', - 'align_double_arrow', - 'newline_after_open_tag', - 'ordered_use', - 'long_array_syntax', - )) +return ConfigBridge::create() ->setUsingCache(true) - ->finder($finder) ; diff --git a/.styleci.yml b/.styleci.yml new file mode 100644 index 000000000..a275a2039 --- /dev/null +++ b/.styleci.yml @@ -0,0 +1,22 @@ +# DO NOT EDIT THIS FILE! +# +# It's auto-generated by sonata-project/dev-kit package. +# +# Package `sllh/php-cs-fixer-styleci-bridge` is required to get it working. + +preset: symfony + +enabled: + - newline_after_open_tag + - ordered_class_elements + - ordered_use + - long_array_syntax +# Comment strict rules for the moment. Should be uncomment later to see StyleCI PR results +# - strict +# - strict_param +# - php_unit_construct +# - php_unit_strict + +finder: + exclude: + - 'Tests/Fixtures' diff --git a/.travis.yml b/.travis.yml index c063ff386..876bd751e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,70 +1,90 @@ +# DO NOT EDIT THIS FILE! +# +# It's auto-generated by sonata-project/dev-kit package. + language: php php: - - hhvm + - '5.3' + - '5.4' + - '5.5' + - '5.6' + - '7.0' - nightly + - hhvm sudo: false cache: directories: - - $HOME/.composer/cache - - $HOME/.cache/pip + - $HOME/.composer/cache/files env: global: - - PATH="$HOME/.composer/vendor/bin:$PATH" + - PATH="$HOME/.local/bin:$PATH" - SYMFONY_DEPRECATIONS_HELPER=weak - TARGET=test matrix: fast_finish: true include: - - php: 7.0 - env: TARGET=cs_dry_run - - php: 7.0 + - php: '7.0' env: TARGET=docs - - php: 5.3 - env: COMPOSER_FLAGS="--prefer-lowest --prefer-stable" - - php: 5.6 - env: SYMFONY_VERSION=2.3.* - - php: 5.6 - env: SYMFONY_VERSION=2.7.* - - php: 5.6 - env: SYMFONY_VERSION=2.8.* - - php: 5.5 - env: SYMFONY_VERSION=3.0.* - - php: 5.6 - env: SYMFONY_VERSION=3.0.* - - php: 7.0 - env: SYMFONY_VERSION=3.0.* - + - php: '5.3' + env: COMPOSER_FLAGS="--prefer-lowest" + - php: '7.0' + env: SYMFONY=2.3.* + - php: '7.0' + env: SYMFONY=2.6.* + - php: '7.0' + env: SYMFONY=2.7.* + - php: '7.0' + env: SYMFONY=2.8.* + - php: '7.0' + env: SYMFONY=dev-master@dev + - php: '7.0' + env: FOS_USER=1.3.* + - php: '7.0' + env: FOS_USER=dev-master@dev + - php: '7.0' + env: SONATA_CORE=3.* + - php: '7.0' + env: SONATA_CORE=dev-master@dev + - php: '7.0' + env: SONATA_ADMIN=3.* + - php: '7.0' + env: SONATA_ADMIN=dev-master@dev + - php: '7.0' + env: SYMFONY_DEPRECATIONS_HELPER=0 allow_failures: - - php: hhvm - php: nightly - - env: SYMFONY_VERSION=3.0.* + - php: hhvm + - env: SYMFONY_DEPRECATIONS_HELPER=0 + - env: SYMFONY=dev-master@dev + - env: FOS_USER=dev-master@dev + - env: SONATA_CORE=dev-master@dev + - env: SONATA_ADMIN=dev-master@dev -before_script: - - (phpenv config-rm xdebug.ini || exit 0) - - mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d && echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - composer selfupdate - - composer config -q -g github-oauth.github.com $GITHUB_OAUTH_TOKEN - - composer global require phpunit/phpunit:@stable fabpot/php-cs-fixer --no-update - - composer global update --prefer-dist --no-interaction - - | - if [ "$SYMFONY_VERSION" == "3.0.*" ]; then - composer require "symfony/http-foundation" "^3.0" --no-update - composer require "symfony/form" "^3.0" --no-update - composer require "symfony/security" "^3.0" --no-update - composer require "symfony/console" "^3.0" --no-update - fi - - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi; - - travis_wait composer update --prefer-dist --no-interaction $COMPOSER_FLAGS - - export PATH=$HOME/.local/bin:$PATH - - pip install -r Resources/doc/requirements.txt --user `whoami` +before_install: + - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then mv "$HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini" /tmp; fi; + - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "memory_limit=3072M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi; + - if [ "$TARGET" = 'test' ]; then composer self-update --stable; fi; + - if [ "$TARGET" = 'test' ]; then composer config --quiet --global github-oauth.github.com $GITHUB_OAUTH_TOKEN; fi; + - if [ "$TARGET" = 'test' ]; then sed --in-place "s/\"dev-master\":/\"dev-${TRAVIS_COMMIT}\":/" composer.json; fi; + - if [ "$TARGET" = 'test' -a "$SYMFONY" != "" ]; then composer require "symfony/symfony:$SYMFONY" --no-update; fi; + - if [ "$TARGET" = 'test' -a "$FOS_USER" != "" ]; then composer require "friendsofsymfony/user-bundle:$FOS_USER" --no-update; fi; + - if [ "$TARGET" = 'test' -a "$SONATA_CORE" != "" ]; then composer require "sonata-project/core-bundle:$SONATA_CORE" --no-update; fi; + - if [ "$TARGET" = 'test' -a "$SONATA_ADMIN" != "" ]; then composer require "sonata-project/admin-bundle:$SONATA_ADMIN" --no-update; fi; -script: - - make $TARGET +install: + - if [ "$TARGET" = 'test' ]; then mkdir "$HOME/bin"; fi; + - if [[ "$TARGET" = 'test' && "$TRAVIS_PHP_VERSION" < '5.6' ]]; then wget https://phar.phpunit.de/phpunit-old.phar --output-document="$HOME/bin/phpunit"; fi + - if [[ "$TARGET" = 'test' && ! "$TRAVIS_PHP_VERSION" < '5.6' ]]; then wget https://phar.phpunit.de/phpunit.phar --output-document="$HOME/bin/phpunit"; fi + - if [ "$TARGET" = 'test' ]; then chmod u+x "$HOME/bin/phpunit"; fi; + - if [ "$TARGET" = 'test' ]; then travis_wait 30 composer update --prefer-dist --no-interaction --prefer-stable $COMPOSER_FLAGS; fi; + - if [ "$TARGET" = 'docs' ]; then pip install -r Resources/doc/requirements.txt --user `whoami`; fi; + +before_script: + - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then mv /tmp/xdebug.ini "$HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d"; fi; -notifications: - webhooks: https://sonata-project.org/bundles/user/master/travis +script: make $TARGET diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8fc8c6f91..b8b662e35 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,51 +1,205 @@ -Sonata respects the symfony’s conventions about contributing to the code. So before going further please review the [contributing documentation of Symfony](http://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request). +# Sonata project contribution -## Reporting bugs +Thanks for you interest onto Sonata projects! -If you happen to find a bug, we kindly request you to report it. However, before submitting it, please: +## Summary - * Check the [project documentation available online](https://sonata-project.org/bundles/) +* [Issues](#issues) +* [Pull Requests](#pull-requests) +* [Label rules]() -Then, if it appears that it’s a real bug, you may report it using Github by following these 3 points: +## Issues - * Check if the bug is not already reported! - * A clear title to resume the issue - * A description of the workflow needed to reproduce the bug, +First, check if you are up to date: is your version still supported, and are +you using the latest patch version? -> _NOTE:_ Don’t hesitate giving as much information as you can (OS, PHP version extensions …) +If you are not sure this is a bug, consider posting your question on [Stack +Overflow](http://stackoverflow.com), using one of the sonata tags. +If you happen to find a bug, we kindly request you to report it. However, +before submitting it, please check the [project documentation available +online](https://sonata-project.org/bundles/). -## Pull requests +Then, if it appears that it is indeed a real bug, you may report it using +Github by following these points are taken care of: -### Matching coding standards +* Check if the bug is not already reported! +* A clear title to sum up the issue +* A description of the workflow needed to reproduce the bug. Please try to make + sentence, dumping an error message by itself is not great. +* If your issue is an error page, you must provide us with a stack trace. With + recent versions of Symfony, you can even get stack traces as plain text at the +end of the page. Just look for "Stack Trace (Plain Text)", and copy/paste what +you see. **Do not** make a screenshot of the stack trace, as screenshots are +not indexed by search engines and will make it difficult for other people to +find your bug report. +* Screenshots should be considered additional data, and therefore, you should + always provide a textual description of the bug. It is strongly recommended +to provide them when reporting UI-related bugs. +* If you need to provide code, make sure you know how to get syntactic + coloration, in particular with [fenced code +blocks](https://help.github.com/articles/creating-and-highlighting-code-blocks/). +When you feel the code is to long, use external code pastebin like +https://gist.github.com/ or http://hastebin.com/ . If this is not sufficient, +just create a repository to show the issue. -Before each commit, be sure to match sonata coding standards by running the following command for fix: +> _NOTE:_ Don't hesitate giving as much information as you can (OS, PHP +> version, extensions...) + +## Pull Requests + +All the sonata team will be glad to review your code changes propositions! :smile: + +But please, read the following before. + +### Coding style + +Each project follows [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/) +and [Symfony Coding Standards](http://symfony.com/doc/current/contributing/code/standards.html) for coding style, +[PSR-4](http://www.php-fig.org/psr/psr-4/) for autoloading. + +Please [install PHP Coding Standard Fixer](http://cs.sensiolabs.org/#installation) +and run this command before committing your modifications: ```bash -make cs +php-cs-fixer fix --verbose ``` -And then, add fixed file to your commit before push. +### Writing a Pull Request + +#### The content + +Ideally, a Pull Request should concern one and **only one** subject, so that it +remains clear, and independent changes can be merged quickly. + +If you want to fix a typo and improve the performance of a process, you should +try as much as possible to it in a **separate** PR, so that we can quickly +merge one while discussing the other. + +The goal is to have a clear commit history and make possible revert easier. + +If you found an issue/typo while writing your change that is not related to +your work, please do another PR for that. In some rare cases, you might be +forced to do it on the same PR. In this kind of situation, please add a comment +on your PR explaining why you feel it is the case. + +#### The Change log + +On each PR, the `CHANGELOG.md` file **has to be updated**. + +There are few cases where the `CHANGELOG.md` file should not be touched: + +* When you fix a bug on an unreleased feature. +* When your PR concerns only the documentation (fix or improvement). + +The change log note has to be put below the `## [Unreleased]` section. + +Your note can be put on one of these sections: + +* `Added` for new features. +* `Changed` for changes in existing functionality. +* `Deprecated` for deprecation of features that will be removed in next major release. +* `Removed` for deprecated features removed in this release. +* `Fixed` for any bug fixes. +* `Security` to invite users to upgrade in case of vulnerabilities. + +More information about the followed changelog format: [keepachangelog.com](http://keepachangelog.com/) + +#### The base branch + +Before writing a PR, you have to check on which branch your changes should be based. + +Each project follows [semver](http://semver.org/) convention for release management. -Be sure to add only **your modified files**. If another files are fixed by cs tools, just revert it before commit. +Here is a short table resuming on which you have to start: -### Sending a Pull Request +Kind of modification | Backward Compatible (BC) | Type of release | Branch to target | Label | +-------------------- | ------------------------ | --------------- | ----------------------- | ----- | +Bug fixes | Yes | Patch | `master` | | +Bug fixes | No (Only if no choice) | Major | `master` | | +Feature | Yes | Minor | `master` | | +Feature | No (Only if no choice) | Major | `master` | | +Deprecation | Yes (Have to) | Minor | `master` | | +Deprecation removal | No (Can't be) | Major | `master` | | -When you send a PR, just make sure that: +Notes: + * Branch `master` is the branch of the **latest stable** minor release and + has to be used for Backward compatible PRs. + * If you PR is not **Backward Compatible** but can be, it **must** be: + * Changing a function/method signature? Prefer create a new one and deprecated the old one. + * Code deletion? Don't. Please deprecate it instead. + * If your BC PR is accepted, you can do a new one on the `master` branch which remove the deprecated code. + * SYMFONY DOC REF (same logic)? -* You add valid test cases. -* Tests are green. -* The related documentation is up-to-date. -* Also don't forget to add a comment when you update a PR with a ping to the maintainer (``@username``), so he/she will get a notification. +Be aware that pull requests with BC breaks could be not accepted +or reported for next major release if BC is not possible. -## Contributing to the documentation +If you are not sure of what to do, don't hesitate to open an issue about your PR project. -You need to install the python tool to check and validate the sphinx syntax: +#### The commit message - pip install -r Resources/doc/requirements.txt +Sonata is a big project with many contributors, and a big part of the job is +being able to understand the code at all times, be it when submitting a PR or +looking at the history. Good commit messages are crucial to achieve this goal. -and you can check the documentation with the command: +There are already a few articles (or even single purpose websites) about this, +we cannot recommend enough the following: - cd Resources/doc/ - rm -rf _build && sphinx-build -W -b html -d _build/doctrees . _build/html +* http://rakeroutes.com/blog/deliberate-git +* http://stopwritingramblingcommitmessages.com +* http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html -The html will be available in the ``_build/html`` folder. +To sum them up, the commit message has to be crystal clear and of course, +related to the PR content. + +The first line of the commit message must be short, keep it under 50 +characters. It must say concisely but *precisely* what you did. The other +lines, if needed, should contain a complete description of *why* you did this. + +Bad commit message subject: + +``` +Update README.md +``` + +Good commit message subject : + +``` +Document how to install the project +``` + +Also, when you specify what you did avoid commit message subjects with "Fix bug +in such and such feature". Saying you are fixing something implies the previous +implementation was wrong and yours is right, which might not be even true. +Instead, state unquestionable technical facts about your changes, not opinions. +Then, in the commit description, explain why you did that and how it fixes +something. +``` +call foo::bar() instead of bar::baz() + +This fixes a bug that arises when doing this or that, because baz() needs a +flux capacitor object that might not be defined. +Fixes #42 +``` + +The description is optional but strongly recommended. It could be asked by the +team if needed. PR will often lead to complicated, hard-to-read conversations +with many links to other web pages. + +The commit description should be able to live without what is said in the PR, +and should ideally sum it up in a crystal clear way, so that people do not have +to open a web browser to understand what you did. +Links to PRs/Issues and external references are of course welcome, but should +not be considered enough. When you reference an issue, make sure to use one of +the keywords described in [the dedicated github +article](https://help.github.com/articles/closing-issues-via-commit-messages/). + +Good commit message with description : + +``` +Change web UI background color to pink + +This is a consensus made on #4242 in addition to #1337. + +We agreed that blank color is boring and so deja vu. Pink is the new way to do. +``` +(Obviously, this commit is fake. :wink:) diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..1b646e0ff --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2010-2016 Thomas Rabaix + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Makefile b/Makefile index 2a2dd2a5e..0394dd007 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,14 @@ -cs: - php-cs-fixer fix --verbose +# DO NOT EDIT THIS FILE! +# +# It's auto-generated by sonata-project/dev-kit package. -cs_dry_run: - php-cs-fixer fix --verbose --dry-run +.PHONY: test docs + +all: + @echo "Please choose a task." test: - phpunit + phpunit -c phpunit.xml.dist docs: cd Resources/doc && sphinx-build -W -b html -d _build/doctrees . _build/html diff --git a/README.md b/README.md index a50dabdd3..0811923b0 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,28 @@ -SonataUserBundle -================ +# Sonata User Bundle -[![Build Status](https://secure.travis-ci.org/sonata-project/SonataUserBundle.png?branch=master)](http://travis-ci.org/sonata-project/SonataUserBundle) +Symfony SonataUserBundle -Integrate the FOS/UserBundle in the Sonata Project --------------------------------------------------- +[![Latest Stable Version](https://poser.pugx.org/sonata-project/user-bundle/v/stable)](https://packagist.org/packages/sonata-project/user-bundle) +[![Latest Unstable Version](https://poser.pugx.org/sonata-project/user-bundle/v/unstable)](https://packagist.org/packages/sonata-project/user-bundle) +[![License](https://poser.pugx.org/sonata-project/user-bundle/license)](https://packagist.org/packages/sonata-project/user-bundle) - - AdminBundle: add user and group management - - EasyExtends: allows to generate Application level model +[![Total Downloads](https://poser.pugx.org/sonata-project/user-bundle/downloads)](https://packagist.org/packages/sonata-project/user-bundle) +[![Monthly Downloads](https://poser.pugx.org/sonata-project/user-bundle/d/monthly)](https://packagist.org/packages/sonata-project/user-bundle) +[![Daily Downloads](https://poser.pugx.org/sonata-project/user-bundle/d/daily)](https://packagist.org/packages/sonata-project/user-bundle) +[![Build Status](https://travis-ci.org/sonata-project/SonataUserBundle.svg?branch=master)](https://travis-ci.org/sonata-project/SonataUserBundle) -Installation ------------- +## Documentation -You have 2 options to initialize the SonataUserBundle, you can select which bundle SonataUserBundle extends +Check out the documentation on the [official website](https://sonata-project.org/bundles/user). - - new Sonata\UserBundle\SonataUserBundle('FOSUserBundle') : the bundle will extend ``FOSUserBundle`` - - new Sonata\UserBundle\SonataUserBundle() : the bundle will NOT extend ``FOSUserBundle`` +## Support +For general support and questions, please use [StackOverflow](http://stackoverflow.com/questions/tagged/sonata). -**Google Groups**: For questions and proposals you can post on this google groups +If you think you find a bug or you have a feature idea to propose, feel free to open a issue +**after looking** at the [contributing guide](CONTRIBUTING.md). -* [Sonata Users](https://groups.google.com/group/sonata-users): Only for user questions -* [Sonata Devs](https://groups.google.com/group/sonata-devs): Only for devs +## License -License -------- - -This bundle is available under the [MIT license](Resources/meta/LICENSE). +This package is available under the [MIT license](LICENSE). From dc2fd778d1c2d5880e1850f351711dec3ca60420 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Fri, 13 May 2016 20:27:37 +0200 Subject: [PATCH 2/7] Applied fixes from StyleCI (#734) --- Admin/Document/GroupAdmin.php | 2 +- Admin/Document/UserAdmin.php | 2 +- Admin/Entity/GroupAdmin.php | 2 +- Admin/Entity/UserAdmin.php | 2 +- Admin/Model/GroupAdmin.php | 2 +- Admin/Model/UserAdmin.php | 60 ++++++++-------- Block/AccountBlockService.php | 8 +-- .../BaseUserProfileBreadcrumbBlockService.php | 4 +- .../UserIndexBreadcrumbBlockService.php | 2 +- .../UserProfileBreadcrumbBlockService.php | 4 +- Block/ProfileMenuBlockService.php | 6 +- Command/TwoStepVerificationCommand.php | 2 +- Controller/AdminResettingController.php | 22 +++--- Controller/AdminSecurityController.php | 32 ++++----- Controller/Api/GroupController.php | 68 +++++++++---------- Controller/Api/UserController.php | 14 ++-- .../ChangePasswordFOSUser1Controller.php | 2 +- Controller/ProfileFOSUser1Controller.php | 8 +-- Controller/RegistrationFOSUser1Controller.php | 2 +- Controller/ResettingFOSUser1Controller.php | 2 +- Controller/SecurityFOSUser1Controller.php | 2 +- .../Compiler/GlobalVariablesCompilerPass.php | 2 +- DependencyInjection/Configuration.php | 14 ++-- DependencyInjection/SonataUserExtension.php | 52 +++++++------- Document/BaseGroup.php | 2 +- Document/BaseUser.php | 2 +- Document/GroupManager.php | 2 +- Document/UserManager.php | 2 +- Entity/BaseGroup.php | 2 +- Entity/BaseUser.php | 6 +- Entity/GroupManager.php | 2 +- Entity/UserManager.php | 2 +- Entity/UserManagerProxy.php | 2 +- Form/Handler/ProfileFormHandler.php | 3 +- Form/Handler/RegistrationFormHandler.php | 3 +- Form/Transformer/RestoreRolesTransformer.php | 5 +- Form/Type/ApiGroupType.php | 3 +- Form/Type/ApiUserType.php | 3 +- Form/Type/ProfileType.php | 29 ++++---- Form/Type/RegistrationFormType.php | 25 ++++--- Form/Type/SecurityRolesType.php | 3 +- Form/Type/UserGenderListType.php | 3 +- GoogleAuthenticator/Helper.php | 2 +- .../InteractiveLoginListener.php | 2 +- GoogleAuthenticator/RequestListener.php | 6 +- Menu/ProfileMenuBuilder.php | 8 +-- Menu/ProfileMenuEvent.php | 2 +- Model/GroupManagerInterface.php | 2 +- Model/User.php | 22 +++--- Model/UserInterface.php | 8 +-- Model/UserManagerInterface.php | 2 +- Security/Authorization/Voter/UserAclVoter.php | 3 +- Security/EditableRolesBuilder.php | 3 +- Serializer/UserSerializerHandler.php | 2 +- SonataUserBundle.php | 24 +++---- Tests/Controller/Api/GroupControllerTest.php | 4 +- Tests/Controller/Api/UserControllerTest.php | 4 +- Tests/Document/BaseGroupTest.php | 2 +- Tests/Document/BaseUserTest.php | 2 +- Tests/Entity/BaseGroupTest.php | 2 +- Tests/Entity/BaseUserTest.php | 2 +- Tests/Entity/GroupManagerTest.php | 32 ++++----- Tests/Entity/UserManagerProxyTest.php | 2 +- Tests/Entity/UserManagerTest.php | 28 ++++---- .../RestoreRolesTransformerTest.php | 14 ++-- Tests/Form/Type/SecurityRolesTypeTest.php | 62 ++++++++--------- Tests/Menu/ProfileMenuBuilderTest.php | 2 +- Tests/Resources/XliffTest.php | 2 +- .../Authorization/Voter/UserAclVoterTest.php | 2 +- Tests/Security/EditableRolesBuilderTest.php | 22 +++--- Tests/bootstrap.php | 6 +- Twig/GlobalVariables.php | 2 +- 72 files changed, 340 insertions(+), 351 deletions(-) diff --git a/Admin/Document/GroupAdmin.php b/Admin/Document/GroupAdmin.php index c984c9a97..bcc407ec7 100644 --- a/Admin/Document/GroupAdmin.php +++ b/Admin/Document/GroupAdmin.php @@ -1,7 +1,7 @@ * diff --git a/Admin/Document/UserAdmin.php b/Admin/Document/UserAdmin.php index f68a1214d..5033b37e2 100644 --- a/Admin/Document/UserAdmin.php +++ b/Admin/Document/UserAdmin.php @@ -1,7 +1,7 @@ * diff --git a/Admin/Entity/GroupAdmin.php b/Admin/Entity/GroupAdmin.php index 4dc01e90a..12ab13b5f 100644 --- a/Admin/Entity/GroupAdmin.php +++ b/Admin/Entity/GroupAdmin.php @@ -1,7 +1,7 @@ * diff --git a/Admin/Entity/UserAdmin.php b/Admin/Entity/UserAdmin.php index 331c3ff4a..eaddcbaba 100644 --- a/Admin/Entity/UserAdmin.php +++ b/Admin/Entity/UserAdmin.php @@ -1,7 +1,7 @@ * diff --git a/Admin/Model/GroupAdmin.php b/Admin/Model/GroupAdmin.php index 9b3d3ba55..7bee823d7 100644 --- a/Admin/Model/GroupAdmin.php +++ b/Admin/Model/GroupAdmin.php @@ -1,7 +1,7 @@ * diff --git a/Admin/Model/UserAdmin.php b/Admin/Model/UserAdmin.php index d7aec5dea..92dd1c4b6 100644 --- a/Admin/Model/UserAdmin.php +++ b/Admin/Model/UserAdmin.php @@ -1,7 +1,7 @@ * @@ -53,6 +53,31 @@ public function getExportFields() }); } + /** + * {@inheritdoc} + */ + public function preUpdate($user) + { + $this->getUserManager()->updateCanonicalFields($user); + $this->getUserManager()->updatePassword($user); + } + + /** + * @param UserManagerInterface $userManager + */ + public function setUserManager(UserManagerInterface $userManager) + { + $this->userManager = $userManager; + } + + /** + * @return UserManagerInterface + */ + public function getUserManager() + { + return $this->userManager; + } + /** * {@inheritdoc} */ @@ -160,17 +185,17 @@ protected function configureFormFields(FormMapper $formMapper) ->end() ->with('Profile') ->add('dateOfBirth', 'sonata_type_date_picker', array( - 'years' => range(1900, $now->format('Y')), + 'years' => range(1900, $now->format('Y')), 'dp_min_date' => '1-1-1900', 'dp_max_date' => $now->format('c'), - 'required' => false, + 'required' => false, )) ->add('firstname', null, array('required' => false)) ->add('lastname', null, array('required' => false)) ->add('website', 'url', array('required' => false)) ->add('biography', 'text', array('required' => false)) ->add('gender', 'sonata_user_gender', array( - 'required' => true, + 'required' => true, 'translation_domain' => $this->getTranslationDomain(), )) ->add('locale', 'locale', array('required' => false)) @@ -202,7 +227,7 @@ protected function configureFormFields(FormMapper $formMapper) ->end() ->with('Roles') ->add('realRoles', 'sonata_security_roles', array( - 'label' => 'form.label_roles', + 'label' => 'form.label_roles', 'expanded' => true, 'multiple' => true, 'required' => false, @@ -215,29 +240,4 @@ protected function configureFormFields(FormMapper $formMapper) ->end() ; } - - /** - * {@inheritdoc} - */ - public function preUpdate($user) - { - $this->getUserManager()->updateCanonicalFields($user); - $this->getUserManager()->updatePassword($user); - } - - /** - * @param UserManagerInterface $userManager - */ - public function setUserManager(UserManagerInterface $userManager) - { - $this->userManager = $userManager; - } - - /** - * @return UserManagerInterface - */ - public function getUserManager() - { - return $this->userManager; - } } diff --git a/Block/AccountBlockService.php b/Block/AccountBlockService.php index d4ac88d35..127e334ac 100644 --- a/Block/AccountBlockService.php +++ b/Block/AccountBlockService.php @@ -1,7 +1,7 @@ * @@ -64,8 +64,8 @@ public function execute(BlockContextInterface $blockContext, Response $response } return $this->renderPrivateResponse($blockContext->getTemplate(), array( - 'user' => $user, - 'block' => $blockContext->getBlock(), + 'user' => $user, + 'block' => $blockContext->getBlock(), 'context' => $blockContext, )); } @@ -77,7 +77,7 @@ public function configureSettings(OptionsResolver $resolver) { $resolver->setDefaults(array( 'template' => 'SonataUserBundle:Block:account.html.twig', - 'ttl' => 0, + 'ttl' => 0, )); } diff --git a/Block/Breadcrumb/BaseUserProfileBreadcrumbBlockService.php b/Block/Breadcrumb/BaseUserProfileBreadcrumbBlockService.php index 2d848a9f8..86a28ce45 100644 --- a/Block/Breadcrumb/BaseUserProfileBreadcrumbBlockService.php +++ b/Block/Breadcrumb/BaseUserProfileBreadcrumbBlockService.php @@ -1,7 +1,7 @@ * @@ -29,7 +29,7 @@ protected function getRootMenu(BlockContextInterface $blockContext) $menu = parent::getRootMenu($blockContext); $menu->addChild('sonata_user_profile_breadcrumb_index', array( - 'route' => 'sonata_user_profile_show', + 'route' => 'sonata_user_profile_show', 'extras' => array('translation_domain' => 'SonataUserBundle'), )); diff --git a/Block/Breadcrumb/UserIndexBreadcrumbBlockService.php b/Block/Breadcrumb/UserIndexBreadcrumbBlockService.php index 043050c88..11a87d677 100644 --- a/Block/Breadcrumb/UserIndexBreadcrumbBlockService.php +++ b/Block/Breadcrumb/UserIndexBreadcrumbBlockService.php @@ -1,7 +1,7 @@ * diff --git a/Block/Breadcrumb/UserProfileBreadcrumbBlockService.php b/Block/Breadcrumb/UserProfileBreadcrumbBlockService.php index 00d8ba176..0579862bd 100644 --- a/Block/Breadcrumb/UserProfileBreadcrumbBlockService.php +++ b/Block/Breadcrumb/UserProfileBreadcrumbBlockService.php @@ -1,7 +1,7 @@ * @@ -36,7 +36,7 @@ protected function getMenu(BlockContextInterface $blockContext) $menu = $this->getRootMenu($blockContext); $menu->addChild('sonata_user_profile_breadcrumb_edit', array( - 'route' => 'sonata_user_profile_edit', + 'route' => 'sonata_user_profile_edit', 'extras' => array('translation_domain' => 'SonataUserBundle'), )); diff --git a/Block/ProfileMenuBlockService.php b/Block/ProfileMenuBlockService.php index 07cc8d6bd..5bad40d29 100644 --- a/Block/ProfileMenuBlockService.php +++ b/Block/ProfileMenuBlockService.php @@ -1,7 +1,7 @@ * @@ -62,7 +62,7 @@ public function configureSettings(OptionsResolver $resolver) parent::configureSettings($resolver); $resolver->setDefaults(array( - 'cache_policy' => 'private', + 'cache_policy' => 'private', 'menu_template' => 'SonataBlockBundle:Block:block_side_menu_template.html.twig', )); } @@ -80,7 +80,7 @@ protected function getMenu(BlockContextInterface $blockContext) $menu = $this->menuBuilder->createProfileMenu( array( 'childrenAttributes' => array('class' => $settings['menu_class']), - 'attributes' => array('class' => $settings['children_class']), + 'attributes' => array('class' => $settings['children_class']), ) ); diff --git a/Command/TwoStepVerificationCommand.php b/Command/TwoStepVerificationCommand.php index 89c56ac51..6cda4d574 100644 --- a/Command/TwoStepVerificationCommand.php +++ b/Command/TwoStepVerificationCommand.php @@ -1,7 +1,7 @@ * diff --git a/Controller/AdminResettingController.php b/Controller/AdminResettingController.php index c795a7b0b..828e52315 100644 --- a/Controller/AdminResettingController.php +++ b/Controller/AdminResettingController.php @@ -1,7 +1,7 @@ * @@ -33,7 +33,7 @@ public function requestAction() return $this->container->get('templating')->renderResponse('SonataUserBundle:Admin:Security/Resetting/request.html.'.$this->getEngine(), array( 'base_template' => $this->container->get('sonata.admin.pool')->getTemplate('layout'), - 'admin_pool' => $this->container->get('sonata.admin.pool'), + 'admin_pool' => $this->container->get('sonata.admin.pool'), )); } @@ -50,15 +50,15 @@ public function sendEmailAction() if (null === $user) { return $this->container->get('templating')->renderResponse('SonataUserBundle:Admin:Security/Resetting/request.html.'.$this->getEngine(), array( 'invalid_username' => $username, - 'base_template' => $this->container->get('sonata.admin.pool')->getTemplate('layout'), - 'admin_pool' => $this->container->get('sonata.admin.pool'), + 'base_template' => $this->container->get('sonata.admin.pool')->getTemplate('layout'), + 'admin_pool' => $this->container->get('sonata.admin.pool'), )); } if ($user->isPasswordRequestNonExpired($this->container->getParameter('fos_user.resetting.token_ttl'))) { return $this->container->get('templating')->renderResponse('SonataUserBundle:Admin:Security/Resetting/passwordAlreadyRequested.html.'.$this->getEngine(), array( - 'base_template' => $this->container->get('sonata.admin.pool')->getTemplate('layout'), - 'admin_pool' => $this->container->get('sonata.admin.pool'), + 'base_template' => $this->container->get('sonata.admin.pool')->getTemplate('layout'), + 'admin_pool' => $this->container->get('sonata.admin.pool'), )); } @@ -91,9 +91,9 @@ public function checkEmailAction() } return $this->container->get('templating')->renderResponse('SonataUserBundle:Admin:Security/Resetting/checkEmail.html.'.$this->getEngine(), array( - 'email' => $email, + 'email' => $email, 'base_template' => $this->container->get('sonata.admin.pool')->getTemplate('layout'), - 'admin_pool' => $this->container->get('sonata.admin.pool'), + 'admin_pool' => $this->container->get('sonata.admin.pool'), )); } @@ -129,10 +129,10 @@ public function resetAction($token) } return $this->container->get('templating')->renderResponse('SonataUserBundle:Admin:Security/Resetting/reset.html.'.$this->getEngine(), array( - 'token' => $token, - 'form' => $form->createView(), + 'token' => $token, + 'form' => $form->createView(), 'base_template' => $this->container->get('sonata.admin.pool')->getTemplate('layout'), - 'admin_pool' => $this->container->get('sonata.admin.pool'), + 'admin_pool' => $this->container->get('sonata.admin.pool'), )); } } diff --git a/Controller/AdminSecurityController.php b/Controller/AdminSecurityController.php index 9657f3435..7a24e9818 100644 --- a/Controller/AdminSecurityController.php +++ b/Controller/AdminSecurityController.php @@ -1,9 +1,9 @@ + * (c) Thomas Rabaix * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -82,14 +82,24 @@ public function loginAction(Request $request = null) return $this->render('SonataUserBundle:Admin:Security/login.html.'.$this->container->getParameter('fos_user.template.engine'), array( 'last_username' => $lastUsername, - 'error' => $error, - 'csrf_token' => $csrfToken, + 'error' => $error, + 'csrf_token' => $csrfToken, 'base_template' => $this->get('sonata.admin.pool')->getTemplate('layout'), - 'admin_pool' => $this->get('sonata.admin.pool'), - 'reset_route' => $resetRoute, // TODO: Deprecated in 2.3, to be removed in 3.0 + 'admin_pool' => $this->get('sonata.admin.pool'), + 'reset_route' => $resetRoute, // TODO: Deprecated in 2.3, to be removed in 3.0 )); } + public function checkAction() + { + throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.'); + } + + public function logoutAction() + { + throw new \RuntimeException('You must activate the logout in your security firewall configuration.'); + } + /** * Renders the login template with the given parameters. Overwrite this function in * an extended controller to provide additional data for the login template. @@ -104,14 +114,4 @@ protected function renderLogin(array $data) return $this->render($template, $data); } - - public function checkAction() - { - throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.'); - } - - public function logoutAction() - { - throw new \RuntimeException('You must activate the logout in your security firewall configuration.'); - } } diff --git a/Controller/Api/GroupController.php b/Controller/Api/GroupController.php index d017e17df..91eeac0f5 100644 --- a/Controller/Api/GroupController.php +++ b/Controller/Api/GroupController.php @@ -1,7 +1,7 @@ * @@ -52,7 +52,7 @@ class GroupController public function __construct(GroupManagerInterface $groupManager, FormFactoryInterface $formFactory) { $this->groupManager = $groupManager; - $this->formFactory = $formFactory; + $this->formFactory = $formFactory; } /** @@ -80,9 +80,9 @@ public function getGroupsAction(ParamFetcherInterface $paramFetcher) 'enabled' => '', ); - $page = $paramFetcher->get('page'); - $limit = $paramFetcher->get('count'); - $sort = $paramFetcher->get('orderBy'); + $page = $paramFetcher->get('page'); + $limit = $paramFetcher->get('count'); + $sort = $paramFetcher->get('orderBy'); $criteria = array_intersect_key($paramFetcher->all(), $supportedFilters); foreach ($criteria as $key => $value) { @@ -176,6 +176,35 @@ public function putGroupAction($id, Request $request) return $this->handleWriteGroup($request, $id); } + /** + * Deletes a group. + * + * @ApiDoc( + * requirements={ + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="group identifier"} + * }, + * statusCodes={ + * 200="Returned when group is successfully deleted", + * 400="Returned when an error has occurred while group deletion", + * 404="Returned when unable to find group" + * } + * ) + * + * @param int $id A Group identifier + * + * @return \FOS\RestBundle\View\View + * + * @throws NotFoundHttpException + */ + public function deleteGroupAction($id) + { + $group = $this->getGroup($id); + + $this->groupManager->deleteGroup($group); + + return array('deleted' => true); + } + /** * Write a Group, this method is used by both POST and PUT action methods. * @@ -211,35 +240,6 @@ protected function handleWriteGroup($request, $id = null) return $form; } - /** - * Deletes a group. - * - * @ApiDoc( - * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="group identifier"} - * }, - * statusCodes={ - * 200="Returned when group is successfully deleted", - * 400="Returned when an error has occurred while group deletion", - * 404="Returned when unable to find group" - * } - * ) - * - * @param int $id A Group identifier - * - * @return \FOS\RestBundle\View\View - * - * @throws NotFoundHttpException - */ - public function deleteGroupAction($id) - { - $group = $this->getGroup($id); - - $this->groupManager->deleteGroup($group); - - return array('deleted' => true); - } - /** * Retrieves group with id $id or throws an exception if it doesn't exist. * diff --git a/Controller/Api/UserController.php b/Controller/Api/UserController.php index b8e8aeef2..18e339edf 100644 --- a/Controller/Api/UserController.php +++ b/Controller/Api/UserController.php @@ -1,7 +1,7 @@ * @@ -59,9 +59,9 @@ class UserController */ public function __construct(UserManagerInterface $userManager, GroupManagerInterface $groupManager, FormFactoryInterface $formFactory) { - $this->userManager = $userManager; + $this->userManager = $userManager; $this->groupManager = $groupManager; - $this->formFactory = $formFactory; + $this->formFactory = $formFactory; } /** @@ -88,12 +88,12 @@ public function getUsersAction(ParamFetcherInterface $paramFetcher) { $supporedCriteria = array( 'enabled' => '', - 'locked' => '', + 'locked' => '', ); - $page = $paramFetcher->get('page'); - $limit = $paramFetcher->get('count'); - $sort = $paramFetcher->get('orderBy'); + $page = $paramFetcher->get('page'); + $limit = $paramFetcher->get('count'); + $sort = $paramFetcher->get('orderBy'); $criteria = array_intersect_key($paramFetcher->all(), $supporedCriteria); foreach ($criteria as $key => $value) { diff --git a/Controller/ChangePasswordFOSUser1Controller.php b/Controller/ChangePasswordFOSUser1Controller.php index f071721df..220e1a974 100644 --- a/Controller/ChangePasswordFOSUser1Controller.php +++ b/Controller/ChangePasswordFOSUser1Controller.php @@ -1,7 +1,7 @@ * diff --git a/Controller/ProfileFOSUser1Controller.php b/Controller/ProfileFOSUser1Controller.php index abe65c079..01bce4ef9 100644 --- a/Controller/ProfileFOSUser1Controller.php +++ b/Controller/ProfileFOSUser1Controller.php @@ -1,9 +1,9 @@ + * (c) Thomas Rabaix * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -37,7 +37,7 @@ public function showAction() } return $this->render('SonataUserBundle:Profile:show.html.twig', array( - 'user' => $user, + 'user' => $user, 'blocks' => $this->container->getParameter('sonata.user.configuration.profile_blocks'), )); } @@ -92,7 +92,7 @@ public function editProfileAction() } return $this->render('SonataUserBundle:Profile:edit_profile.html.twig', array( - 'form' => $form->createView(), + 'form' => $form->createView(), 'breadcrumb_context' => 'user_profile', )); } diff --git a/Controller/RegistrationFOSUser1Controller.php b/Controller/RegistrationFOSUser1Controller.php index 24048348a..d7f78a5eb 100644 --- a/Controller/RegistrationFOSUser1Controller.php +++ b/Controller/RegistrationFOSUser1Controller.php @@ -1,7 +1,7 @@ * diff --git a/Controller/ResettingFOSUser1Controller.php b/Controller/ResettingFOSUser1Controller.php index 59d079c10..be34e5644 100644 --- a/Controller/ResettingFOSUser1Controller.php +++ b/Controller/ResettingFOSUser1Controller.php @@ -1,7 +1,7 @@ * diff --git a/Controller/SecurityFOSUser1Controller.php b/Controller/SecurityFOSUser1Controller.php index d5d65581b..ab454cb76 100644 --- a/Controller/SecurityFOSUser1Controller.php +++ b/Controller/SecurityFOSUser1Controller.php @@ -1,7 +1,7 @@ * diff --git a/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php b/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php index 0fd383000..f2cc93d21 100644 --- a/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php +++ b/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php @@ -1,7 +1,7 @@ * diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 142ecec43..ba314a252 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -1,7 +1,7 @@ * @@ -216,15 +216,15 @@ protected function getProfileMenuDefaultValues() { return array( array( - 'route' => 'sonata_user_profile_edit', - 'label' => 'link_edit_profile', - 'domain' => 'SonataUserBundle', + 'route' => 'sonata_user_profile_edit', + 'label' => 'link_edit_profile', + 'domain' => 'SonataUserBundle', 'route_parameters' => array(), ), array( - 'route' => 'sonata_user_profile_edit_authentication', - 'label' => 'link_edit_authentication', - 'domain' => 'SonataUserBundle', + 'route' => 'sonata_user_profile_edit_authentication', + 'label' => 'link_edit_authentication', + 'domain' => 'SonataUserBundle', 'route_parameters' => array(), ), ); diff --git a/DependencyInjection/SonataUserExtension.php b/DependencyInjection/SonataUserExtension.php index d92b751ab..4741a5bfb 100644 --- a/DependencyInjection/SonataUserExtension.php +++ b/DependencyInjection/SonataUserExtension.php @@ -1,7 +1,7 @@ * @@ -93,18 +93,6 @@ public function load(array $configs, ContainerBuilder $container) $this->configureMenu($config, $container); } - /** - * Adds aliases for user & group managers depending on $managerType. - * - * @param ContainerBuilder $container - * @param $managerType - */ - protected function aliasManagers(ContainerBuilder $container, $managerType) - { - $container->setAlias('sonata.user.user_manager', sprintf('sonata.user.%s.user_manager', $managerType)); - $container->setAlias('sonata.user.group_manager', sprintf('sonata.user.%s.group_manager', $managerType)); - } - /** * @param array $config * @@ -120,7 +108,7 @@ public function fixImpersonating(array $config) if (isset($config['impersonating_route'])) { $config['impersonating'] = array( - 'route' => $config['impersonating_route'], + 'route' => $config['impersonating_route'], 'parameters' => array(), ); } @@ -180,10 +168,10 @@ public function addDefaults(array $config) throw new \InvalidArgumentException(sprintf('Invalid manager type "%s".', $config['manager_type'])); } - $defaultConfig['class']['user'] = sprintf('Application\\Sonata\\UserBundle\\%s\\User', $modelType); + $defaultConfig['class']['user'] = sprintf('Application\\Sonata\\UserBundle\\%s\\User', $modelType); $defaultConfig['class']['group'] = sprintf('Application\\Sonata\\UserBundle\\%s\\Group', $modelType); - $defaultConfig['admin']['user']['class'] = sprintf('Sonata\\UserBundle\\Admin\\%s\\UserAdmin', $modelType); + $defaultConfig['admin']['user']['class'] = sprintf('Sonata\\UserBundle\\Admin\\%s\\UserAdmin', $modelType); $defaultConfig['admin']['group']['class'] = sprintf('Sonata\\UserBundle\\Admin\\%s\\GroupAdmin', $modelType); return array_replace_recursive($defaultConfig, $config); @@ -251,22 +239,22 @@ public function registerDoctrineMapping(array $config) $collector = DoctrineCollector::getInstance(); $collector->addAssociation($config['class']['user'], 'mapManyToMany', array( - 'fieldName' => 'groups', - 'targetEntity' => $config['class']['group'], - 'cascade' => array(), - 'joinTable' => array( - 'name' => $config['table']['user_group'], + 'fieldName' => 'groups', + 'targetEntity' => $config['class']['group'], + 'cascade' => array(), + 'joinTable' => array( + 'name' => $config['table']['user_group'], 'joinColumns' => array( array( - 'name' => 'user_id', + 'name' => 'user_id', 'referencedColumnName' => 'id', - 'onDelete' => 'CASCADE', + 'onDelete' => 'CASCADE', ), ), 'inverseJoinColumns' => array(array( - 'name' => 'group_id', + 'name' => 'group_id', 'referencedColumnName' => 'id', - 'onDelete' => 'CASCADE', + 'onDelete' => 'CASCADE', )), ), )); @@ -310,7 +298,7 @@ public function configureRegistration(array $config, ContainerBuilder $container if (isset($bundles['MopaBootstrapBundle'])) { $options = array( 'horizontal_input_wrapper_class' => 'col-lg-8', - 'horizontal_label_class' => 'col-lg-4 control-label', + 'horizontal_label_class' => 'col-lg-4 control-label', ); } else { $options = array(); @@ -333,4 +321,16 @@ public function configureMenu(array $config, ContainerBuilder $container) { $container->getDefinition('sonata.user.profile.menu_builder')->replaceArgument(2, $config['profile']['menu']); } + + /** + * Adds aliases for user & group managers depending on $managerType. + * + * @param ContainerBuilder $container + * @param $managerType + */ + protected function aliasManagers(ContainerBuilder $container, $managerType) + { + $container->setAlias('sonata.user.user_manager', sprintf('sonata.user.%s.user_manager', $managerType)); + $container->setAlias('sonata.user.group_manager', sprintf('sonata.user.%s.group_manager', $managerType)); + } } diff --git a/Document/BaseGroup.php b/Document/BaseGroup.php index b298e1346..abacfe8c8 100644 --- a/Document/BaseGroup.php +++ b/Document/BaseGroup.php @@ -1,7 +1,7 @@ * diff --git a/Document/BaseUser.php b/Document/BaseUser.php index e9a239a34..d494a51fd 100644 --- a/Document/BaseUser.php +++ b/Document/BaseUser.php @@ -1,7 +1,7 @@ * diff --git a/Document/GroupManager.php b/Document/GroupManager.php index e83d435b3..4739dee15 100644 --- a/Document/GroupManager.php +++ b/Document/GroupManager.php @@ -1,7 +1,7 @@ * diff --git a/Document/UserManager.php b/Document/UserManager.php index af2f49c4e..a8fdc8b00 100644 --- a/Document/UserManager.php +++ b/Document/UserManager.php @@ -1,7 +1,7 @@ * diff --git a/Entity/BaseGroup.php b/Entity/BaseGroup.php index 3f43ee91c..9c3dcecf2 100644 --- a/Entity/BaseGroup.php +++ b/Entity/BaseGroup.php @@ -1,7 +1,7 @@ * diff --git a/Entity/BaseUser.php b/Entity/BaseUser.php index 876b94858..8df7f9d8c 100644 --- a/Entity/BaseUser.php +++ b/Entity/BaseUser.php @@ -1,7 +1,7 @@ * @@ -45,8 +45,8 @@ public static function getGenderList() { return array( UserInterface::GENDER_UNKNOWN => 'gender_unknown', - UserInterface::GENDER_FEMALE => 'gender_female', - UserInterface::GENDER_MALE => 'gender_male', + UserInterface::GENDER_FEMALE => 'gender_female', + UserInterface::GENDER_MALE => 'gender_male', ); } } diff --git a/Entity/GroupManager.php b/Entity/GroupManager.php index ee358f6c4..fa407aed6 100644 --- a/Entity/GroupManager.php +++ b/Entity/GroupManager.php @@ -1,7 +1,7 @@ * diff --git a/Entity/UserManager.php b/Entity/UserManager.php index 5f76c4cb0..0945e5573 100644 --- a/Entity/UserManager.php +++ b/Entity/UserManager.php @@ -1,7 +1,7 @@ * diff --git a/Entity/UserManagerProxy.php b/Entity/UserManagerProxy.php index 3828e05e6..886c78520 100644 --- a/Entity/UserManagerProxy.php +++ b/Entity/UserManagerProxy.php @@ -1,7 +1,7 @@ * diff --git a/Form/Handler/ProfileFormHandler.php b/Form/Handler/ProfileFormHandler.php index 60910329f..825d211dc 100644 --- a/Form/Handler/ProfileFormHandler.php +++ b/Form/Handler/ProfileFormHandler.php @@ -1,13 +1,12 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - * */ namespace Sonata\UserBundle\Form\Handler; diff --git a/Form/Handler/RegistrationFormHandler.php b/Form/Handler/RegistrationFormHandler.php index 39cc49c61..02a28ae80 100644 --- a/Form/Handler/RegistrationFormHandler.php +++ b/Form/Handler/RegistrationFormHandler.php @@ -1,13 +1,12 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - * */ namespace Sonata\UserBundle\Form\Handler; diff --git a/Form/Transformer/RestoreRolesTransformer.php b/Form/Transformer/RestoreRolesTransformer.php index 11d448c36..79acea7f2 100644 --- a/Form/Transformer/RestoreRolesTransformer.php +++ b/Form/Transformer/RestoreRolesTransformer.php @@ -1,13 +1,12 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - * */ namespace Sonata\UserBundle\Form\Transformer; @@ -25,7 +24,7 @@ class RestoreRolesTransformer implements DataTransformerInterface /** * @var EditableRolesBuilder|null */ - protected $rolesBuilder = null; + protected $rolesBuilder = null; /** * @param EditableRolesBuilder $rolesBuilder diff --git a/Form/Type/ApiGroupType.php b/Form/Type/ApiGroupType.php index e07e8c449..18de24bb1 100644 --- a/Form/Type/ApiGroupType.php +++ b/Form/Type/ApiGroupType.php @@ -1,13 +1,12 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - * */ namespace Sonata\UserBundle\Form\Type; diff --git a/Form/Type/ApiUserType.php b/Form/Type/ApiUserType.php index 9f53d7630..5b484a6bd 100644 --- a/Form/Type/ApiUserType.php +++ b/Form/Type/ApiUserType.php @@ -1,13 +1,12 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - * */ namespace Sonata\UserBundle\Form\Type; diff --git a/Form/Type/ProfileType.php b/Form/Type/ProfileType.php index ed79c359f..ccc065a96 100644 --- a/Form/Type/ProfileType.php +++ b/Form/Type/ProfileType.php @@ -1,13 +1,12 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - * */ namespace Sonata\UserBundle\Form\Type; @@ -40,45 +39,45 @@ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('gender', 'sonata_user_gender', array( - 'label' => 'form.label_gender', - 'required' => true, + 'label' => 'form.label_gender', + 'required' => true, 'translation_domain' => 'SonataUserBundle', - 'choices' => array( + 'choices' => array( UserInterface::GENDER_FEMALE => 'gender_female', - UserInterface::GENDER_MALE => 'gender_male', + UserInterface::GENDER_MALE => 'gender_male', ), )) ->add('firstname', null, array( - 'label' => 'form.label_firstname', + 'label' => 'form.label_firstname', 'required' => false, )) ->add('lastname', null, array( - 'label' => 'form.label_lastname', + 'label' => 'form.label_lastname', 'required' => false, )) ->add('dateOfBirth', 'birthday', array( - 'label' => 'form.label_date_of_birth', + 'label' => 'form.label_date_of_birth', 'required' => false, - 'widget' => 'single_text', + 'widget' => 'single_text', )) ->add('website', 'url', array( - 'label' => 'form.label_website', + 'label' => 'form.label_website', 'required' => false, )) ->add('biography', 'textarea', array( - 'label' => 'form.label_biography', + 'label' => 'form.label_biography', 'required' => false, )) ->add('locale', 'locale', array( - 'label' => 'form.label_locale', + 'label' => 'form.label_locale', 'required' => false, )) ->add('timezone', 'timezone', array( - 'label' => 'form.label_timezone', + 'label' => 'form.label_timezone', 'required' => false, )) ->add('phone', null, array( - 'label' => 'form.label_phone', + 'label' => 'form.label_phone', 'required' => false, )) ; diff --git a/Form/Type/RegistrationFormType.php b/Form/Type/RegistrationFormType.php index e2185be12..ffe29e9eb 100644 --- a/Form/Type/RegistrationFormType.php +++ b/Form/Type/RegistrationFormType.php @@ -1,9 +1,9 @@ + * (c) Thomas Rabaix * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -18,15 +18,14 @@ class RegistrationFormType extends AbstractType { - /** - * @var string - */ - private $class; - /** * @var array */ protected $mergeOptions; + /** + * @var string + */ + private $class; /** * @param string $class The User class name @@ -34,7 +33,7 @@ class RegistrationFormType extends AbstractType */ public function __construct($class, array $mergeOptions = array()) { - $this->class = $class; + $this->class = $class; $this->mergeOptions = $mergeOptions; } @@ -45,16 +44,16 @@ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('username', null, array_merge(array( - 'label' => 'form.username', + 'label' => 'form.username', 'translation_domain' => 'SonataUserBundle', ), $this->mergeOptions)) ->add('email', 'email', array_merge(array( - 'label' => 'form.email', + 'label' => 'form.email', 'translation_domain' => 'SonataUserBundle', ), $this->mergeOptions)) ->add('plainPassword', 'repeated', array_merge(array( - 'type' => 'password', - 'options' => array('translation_domain' => 'SonataUserBundle'), + 'type' => 'password', + 'options' => array('translation_domain' => 'SonataUserBundle'), 'first_options' => array_merge(array( 'label' => 'form.password', ), $this->mergeOptions), @@ -83,7 +82,7 @@ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'data_class' => $this->class, - 'intention' => 'registration', + 'intention' => 'registration', )); } diff --git a/Form/Type/SecurityRolesType.php b/Form/Type/SecurityRolesType.php index 2963bd8d0..f0ce97f99 100644 --- a/Form/Type/SecurityRolesType.php +++ b/Form/Type/SecurityRolesType.php @@ -1,13 +1,12 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - * */ namespace Sonata\UserBundle\Form\Type; diff --git a/Form/Type/UserGenderListType.php b/Form/Type/UserGenderListType.php index bd9983f79..abd93e974 100644 --- a/Form/Type/UserGenderListType.php +++ b/Form/Type/UserGenderListType.php @@ -1,13 +1,12 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - * */ namespace Sonata\UserBundle\Form\Type; diff --git a/GoogleAuthenticator/Helper.php b/GoogleAuthenticator/Helper.php index e2ce137f5..9e5d6dba7 100644 --- a/GoogleAuthenticator/Helper.php +++ b/GoogleAuthenticator/Helper.php @@ -1,7 +1,7 @@ * diff --git a/GoogleAuthenticator/InteractiveLoginListener.php b/GoogleAuthenticator/InteractiveLoginListener.php index 05c88cab0..fa31dcf45 100644 --- a/GoogleAuthenticator/InteractiveLoginListener.php +++ b/GoogleAuthenticator/InteractiveLoginListener.php @@ -1,7 +1,7 @@ * diff --git a/GoogleAuthenticator/RequestListener.php b/GoogleAuthenticator/RequestListener.php index 332ac6880..55da89510 100644 --- a/GoogleAuthenticator/RequestListener.php +++ b/GoogleAuthenticator/RequestListener.php @@ -1,7 +1,7 @@ * @@ -65,10 +65,10 @@ public function onCoreRequest(GetResponseEvent $event) return; } - $key = $this->helper->getSessionKey($this->securityContext->getToken()); + $key = $this->helper->getSessionKey($this->securityContext->getToken()); $request = $event->getRequest(); $session = $event->getRequest()->getSession(); - $user = $this->securityContext->getToken()->getUser(); + $user = $this->securityContext->getToken()->getUser(); if (!$session->has($key)) { return; diff --git a/Menu/ProfileMenuBuilder.php b/Menu/ProfileMenuBuilder.php index 84af10282..b587c99eb 100644 --- a/Menu/ProfileMenuBuilder.php +++ b/Menu/ProfileMenuBuilder.php @@ -1,7 +1,7 @@ * @@ -52,9 +52,9 @@ class ProfileMenuBuilder */ public function __construct(FactoryInterface $factory, TranslatorInterface $translator, array $routes, EventDispatcherInterface $eventDispatcher) { - $this->factory = $factory; - $this->translator = $translator; - $this->routes = $routes; + $this->factory = $factory; + $this->translator = $translator; + $this->routes = $routes; $this->eventDispatcher = $eventDispatcher; } diff --git a/Menu/ProfileMenuEvent.php b/Menu/ProfileMenuEvent.php index cb992a56e..58cc29599 100644 --- a/Menu/ProfileMenuEvent.php +++ b/Menu/ProfileMenuEvent.php @@ -1,7 +1,7 @@ * diff --git a/Model/GroupManagerInterface.php b/Model/GroupManagerInterface.php index c5135f803..17fd6d3e6 100644 --- a/Model/GroupManagerInterface.php +++ b/Model/GroupManagerInterface.php @@ -1,7 +1,7 @@ * diff --git a/Model/User.php b/Model/User.php index 0e2615724..9c01c342d 100644 --- a/Model/User.php +++ b/Model/User.php @@ -1,7 +1,7 @@ * @@ -128,6 +128,16 @@ abstract class User extends AbstractedUser implements UserInterface */ protected $token; + /** + * Returns a string representation. + * + * @return string + */ + public function __toString() + { + return $this->getUsername() ?: '-'; + } + /** * Sets the creation date. * @@ -224,16 +234,6 @@ public function setCredentialsExpireAt(\DateTime $date = null) return $this; } - /** - * Returns a string representation. - * - * @return string - */ - public function __toString() - { - return $this->getUsername() ?: '-'; - } - /** * Sets the user groups. * diff --git a/Model/UserInterface.php b/Model/UserInterface.php index 8e117062f..c0abe3ff6 100644 --- a/Model/UserInterface.php +++ b/Model/UserInterface.php @@ -1,7 +1,7 @@ * @@ -13,9 +13,9 @@ interface UserInterface extends \FOS\UserBundle\Model\UserInterface { - const GENDER_FEMALE = 'f'; - const GENDER_MALE = 'm'; - const GENDER_MAN = 'm'; // @deprecated + const GENDER_FEMALE = 'f'; + const GENDER_MALE = 'm'; + const GENDER_MAN = 'm'; // @deprecated const GENDER_UNKNOWN = 'u'; /** diff --git a/Model/UserManagerInterface.php b/Model/UserManagerInterface.php index 9cec3b7fb..cce8c86f3 100644 --- a/Model/UserManagerInterface.php +++ b/Model/UserManagerInterface.php @@ -1,7 +1,7 @@ * diff --git a/Security/Authorization/Voter/UserAclVoter.php b/Security/Authorization/Voter/UserAclVoter.php index 69ac0591c..be197aefb 100644 --- a/Security/Authorization/Voter/UserAclVoter.php +++ b/Security/Authorization/Voter/UserAclVoter.php @@ -1,13 +1,12 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - * */ namespace Sonata\UserBundle\Security\Authorization\Voter; diff --git a/Security/EditableRolesBuilder.php b/Security/EditableRolesBuilder.php index 91ee6540b..28590b4d3 100644 --- a/Security/EditableRolesBuilder.php +++ b/Security/EditableRolesBuilder.php @@ -1,13 +1,12 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - * */ namespace Sonata\UserBundle\Security; diff --git a/Serializer/UserSerializerHandler.php b/Serializer/UserSerializerHandler.php index 52c1cbf44..2e04fa26b 100644 --- a/Serializer/UserSerializerHandler.php +++ b/Serializer/UserSerializerHandler.php @@ -1,7 +1,7 @@ * diff --git a/SonataUserBundle.php b/SonataUserBundle.php index dc53854e3..320eefc17 100644 --- a/SonataUserBundle.php +++ b/SonataUserBundle.php @@ -1,7 +1,7 @@ * @@ -60,18 +60,18 @@ public function boot() public function registerFormMapping() { FormHelper::registerFormTypeMapping(array( - 'fos_user_username' => 'FOS\UserBundle\Form\Type\UsernameFormType', - 'fos_user_profile' => 'FOS\UserBundle\Form\Type\ProfileFormType', - 'fos_user_registration' => 'FOS\UserBundle\Form\Type\RegistrationFormType', - 'fos_user_change_password' => 'FOS\UserBundle\Form\Type\ChangePasswordFormType', - 'fos_user_resetting' => 'FOS\UserBundle\Form\Type\ResettingFormType', - 'fos_user_group' => 'FOS\UserBundle\Form\Type\GroupFormType', - 'sonata_security_roles' => 'Sonata\UserBundle\Form\Type\SecurityRolesType', - 'sonata_user_profile' => 'Sonata\UserBundle\Form\Type\ProfileType', - 'sonata_user_gender' => 'Sonata\UserBundle\Form\Type\UserGenderListType', - 'sonata_user_registration' => 'Sonata\UserBundle\Form\Type\RegistrationFormType', + 'fos_user_username' => 'FOS\UserBundle\Form\Type\UsernameFormType', + 'fos_user_profile' => 'FOS\UserBundle\Form\Type\ProfileFormType', + 'fos_user_registration' => 'FOS\UserBundle\Form\Type\RegistrationFormType', + 'fos_user_change_password' => 'FOS\UserBundle\Form\Type\ChangePasswordFormType', + 'fos_user_resetting' => 'FOS\UserBundle\Form\Type\ResettingFormType', + 'fos_user_group' => 'FOS\UserBundle\Form\Type\GroupFormType', + 'sonata_security_roles' => 'Sonata\UserBundle\Form\Type\SecurityRolesType', + 'sonata_user_profile' => 'Sonata\UserBundle\Form\Type\ProfileType', + 'sonata_user_gender' => 'Sonata\UserBundle\Form\Type\UserGenderListType', + 'sonata_user_registration' => 'Sonata\UserBundle\Form\Type\RegistrationFormType', 'sonata_user_api_form_group' => 'Sonata\UserBundle\Form\Type\ApiGroupType', - 'sonata_user_api_form_user' => 'Sonata\UserBundle\Form\Type\ApiUserType', + 'sonata_user_api_form_user' => 'Sonata\UserBundle\Form\Type\ApiUserType', )); } } diff --git a/Tests/Controller/Api/GroupControllerTest.php b/Tests/Controller/Api/GroupControllerTest.php index 5caf9b684..51eadb175 100644 --- a/Tests/Controller/Api/GroupControllerTest.php +++ b/Tests/Controller/Api/GroupControllerTest.php @@ -1,7 +1,7 @@ * @@ -24,7 +24,7 @@ class GroupControllerTest extends \PHPUnit_Framework_TestCase { public function testGetGroupsAction() { - $group = $this->getMock('FOS\UserBundle\Model\GroupInterface'); + $group = $this->getMock('FOS\UserBundle\Model\GroupInterface'); $groupManager = $this->getMock('Sonata\UserBundle\Model\GroupManagerInterface'); $groupManager->expects($this->once())->method('getPager')->will($this->returnValue(array($group))); diff --git a/Tests/Controller/Api/UserControllerTest.php b/Tests/Controller/Api/UserControllerTest.php index d6141e367..dcb59bc73 100644 --- a/Tests/Controller/Api/UserControllerTest.php +++ b/Tests/Controller/Api/UserControllerTest.php @@ -1,7 +1,7 @@ * @@ -24,7 +24,7 @@ class UserControllerTest extends \PHPUnit_Framework_TestCase { public function testGetUsersAction() { - $user = $this->getMock('Sonata\UserBundle\Model\UserInterface'); + $user = $this->getMock('Sonata\UserBundle\Model\UserInterface'); $userManager = $this->getMock('Sonata\UserBundle\Model\UserManagerInterface'); $userManager->expects($this->once())->method('getPager')->will($this->returnValue(array())); diff --git a/Tests/Document/BaseGroupTest.php b/Tests/Document/BaseGroupTest.php index cd87a7711..aebe5af79 100644 --- a/Tests/Document/BaseGroupTest.php +++ b/Tests/Document/BaseGroupTest.php @@ -1,7 +1,7 @@ * diff --git a/Tests/Document/BaseUserTest.php b/Tests/Document/BaseUserTest.php index d38705764..14e5a8fb6 100644 --- a/Tests/Document/BaseUserTest.php +++ b/Tests/Document/BaseUserTest.php @@ -1,7 +1,7 @@ * diff --git a/Tests/Entity/BaseGroupTest.php b/Tests/Entity/BaseGroupTest.php index 7b649270c..94a3cf0c0 100644 --- a/Tests/Entity/BaseGroupTest.php +++ b/Tests/Entity/BaseGroupTest.php @@ -1,7 +1,7 @@ * diff --git a/Tests/Entity/BaseUserTest.php b/Tests/Entity/BaseUserTest.php index 6d12502a2..a15e2be9e 100644 --- a/Tests/Entity/BaseUserTest.php +++ b/Tests/Entity/BaseUserTest.php @@ -1,7 +1,7 @@ * diff --git a/Tests/Entity/GroupManagerTest.php b/Tests/Entity/GroupManagerTest.php index 645c957c2..82669c318 100644 --- a/Tests/Entity/GroupManagerTest.php +++ b/Tests/Entity/GroupManagerTest.php @@ -1,7 +1,7 @@ * @@ -19,21 +19,6 @@ */ class GroupManagerTest extends \PHPUnit_Framework_TestCase { - /** - * @param $qbCallback - * - * @return GroupManager - */ - protected function getUserManager($qbCallback) - { - $em = EntityManagerMockFactory::create($this, $qbCallback, array( - 'name', - 'roles', - )); - - return new GroupManager($em, 'Sonata\UserBundle\Entity\BaseGroup'); - } - public function testGetPager() { $self = $this; @@ -94,4 +79,19 @@ public function testGetPagerWithDisabledUsers() }) ->getPager(array('enabled' => false), 1); } + + /** + * @param $qbCallback + * + * @return GroupManager + */ + protected function getUserManager($qbCallback) + { + $em = EntityManagerMockFactory::create($this, $qbCallback, array( + 'name', + 'roles', + )); + + return new GroupManager($em, 'Sonata\UserBundle\Entity\BaseGroup'); + } } diff --git a/Tests/Entity/UserManagerProxyTest.php b/Tests/Entity/UserManagerProxyTest.php index 5e82a8dc3..8dba862f5 100644 --- a/Tests/Entity/UserManagerProxyTest.php +++ b/Tests/Entity/UserManagerProxyTest.php @@ -1,7 +1,7 @@ * diff --git a/Tests/Entity/UserManagerTest.php b/Tests/Entity/UserManagerTest.php index 2d505f43b..f1286a00b 100644 --- a/Tests/Entity/UserManagerTest.php +++ b/Tests/Entity/UserManagerTest.php @@ -1,7 +1,7 @@ * @@ -19,19 +19,6 @@ */ class UserManagerTest extends \PHPUnit_Framework_TestCase { - protected function getUserManager($qbCallback) - { - $em = EntityManagerMockFactory::create($this, $qbCallback, array( - 'username', - 'email', - )); - - $encoder = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface'); - $canonicalizer = $this->getMock('FOS\UserBundle\Util\CanonicalizerInterface'); - - return new UserManager($encoder, $canonicalizer, $canonicalizer, $em, 'Sonata\UserBundle\Entity\BaseUser'); - } - public function testGetPager() { $self = $this; @@ -261,4 +248,17 @@ public function testGetPagerWithDisabledAndLockedUsers() }) ->getPager(array('enabled' => false, 'locked' => true), 1); } + + protected function getUserManager($qbCallback) + { + $em = EntityManagerMockFactory::create($this, $qbCallback, array( + 'username', + 'email', + )); + + $encoder = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface'); + $canonicalizer = $this->getMock('FOS\UserBundle\Util\CanonicalizerInterface'); + + return new UserManager($encoder, $canonicalizer, $canonicalizer, $em, 'Sonata\UserBundle\Entity\BaseUser'); + } } diff --git a/Tests/Form/Transformer/RestoreRolesTransformerTest.php b/Tests/Form/Transformer/RestoreRolesTransformerTest.php index 30e38e4fa..bcd9b8128 100644 --- a/Tests/Form/Transformer/RestoreRolesTransformerTest.php +++ b/Tests/Form/Transformer/RestoreRolesTransformerTest.php @@ -1,7 +1,7 @@ * @@ -108,11 +108,11 @@ public function testReverseTransformRevokedHierarchicalRole() ->getMock(); $availableRoles = array( - 'ROLE_SONATA_ADMIN' => 'ROLE_SONATA_ADMIN', + 'ROLE_SONATA_ADMIN' => 'ROLE_SONATA_ADMIN', 'ROLE_COMPANY_PERSONAL_MODERATOR' => 'ROLE_COMPANY_PERSONAL_MODERATOR: ROLE_COMPANY_USER', - 'ROLE_COMPANY_NEWS_MODERATOR' => 'ROLE_COMPANY_NEWS_MODERATOR: ROLE_COMPANY_USER', - 'ROLE_COMPANY_BOOKKEEPER' => 'ROLE_COMPANY_BOOKKEEPER: ROLE_COMPANY_USER', - 'ROLE_USER' => 'ROLE_USER', + 'ROLE_COMPANY_NEWS_MODERATOR' => 'ROLE_COMPANY_NEWS_MODERATOR: ROLE_COMPANY_USER', + 'ROLE_COMPANY_BOOKKEEPER' => 'ROLE_COMPANY_BOOKKEEPER: ROLE_COMPANY_USER', + 'ROLE_USER' => 'ROLE_USER', ); $roleBuilder->expects($this->once())->method('getRoles')->will($this->returnValue(array($availableRoles, array()))); @@ -135,8 +135,8 @@ public function testReverseTransformHiddenRole() ->getMock(); $availableRoles = array( - 'ROLE_SONATA_ADMIN' => 'ROLE_SONATA_ADMIN', - 'ROLE_ADMIN' => 'ROLE_ADMIN: ROLE_USER ROLE_COMPANY_ADMIN', + 'ROLE_SONATA_ADMIN' => 'ROLE_SONATA_ADMIN', + 'ROLE_ADMIN' => 'ROLE_ADMIN: ROLE_USER ROLE_COMPANY_ADMIN', ); $roleBuilder->expects($this->once())->method('getRoles')->will($this->returnValue(array($availableRoles, array()))); diff --git a/Tests/Form/Type/SecurityRolesTypeTest.php b/Tests/Form/Type/SecurityRolesTypeTest.php index 0bf9cb88c..6faf5c803 100755 --- a/Tests/Form/Type/SecurityRolesTypeTest.php +++ b/Tests/Form/Type/SecurityRolesTypeTest.php @@ -1,7 +1,7 @@ * @@ -26,28 +26,6 @@ class SecurityRolesTypeTest extends TypeTestCase { protected $roleBuilder; - protected function getExtensions() - { - $this->roleBuilder = $roleBuilder = $this->getMockBuilder('Sonata\UserBundle\Security\EditableRolesBuilder') - ->disableOriginalConstructor() - ->getMock(); - - $this->roleBuilder->expects($this->any())->method('getRoles')->will($this->returnValue(array( - 0 => array( - 'ROLE_FOO' => 'ROLE_FOO', - 'ROLE_USER' => 'ROLE_USER', - 'ROLE_ADMIN' => 'ROLE_ADMIN: ROLE_USER', - ), - 1 => array(), - ))); - - $childType = new SecurityRolesType($this->roleBuilder); - - return array(new PreloadedExtension(array( - $childType->getName() => $childType, - ), array())); - } - public function testGetDefaultOptions() { $type = new SecurityRolesType($this->roleBuilder); @@ -76,14 +54,6 @@ public function testGetParent() ); } - private function getSecurityRolesTypeName() - { - return - method_exists('Symfony\Component\Form\FormTypeInterface', 'setDefaultOptions') ? - 'sonata_security_roles' : - 'Sonata\UserBundle\Form\Type\SecurityRolesType'; - } - public function testSubmitValidData() { $form = $this->factory->create($this->getSecurityRolesTypeName(), null, array( @@ -130,4 +100,34 @@ public function testSubmitWithHiddenRoleData() $this->assertCount(2, $form->getData()); $this->assertContains('ROLE_SUPER_ADMIN', $form->getData()); } + + protected function getExtensions() + { + $this->roleBuilder = $roleBuilder = $this->getMockBuilder('Sonata\UserBundle\Security\EditableRolesBuilder') + ->disableOriginalConstructor() + ->getMock(); + + $this->roleBuilder->expects($this->any())->method('getRoles')->will($this->returnValue(array( + 0 => array( + 'ROLE_FOO' => 'ROLE_FOO', + 'ROLE_USER' => 'ROLE_USER', + 'ROLE_ADMIN' => 'ROLE_ADMIN: ROLE_USER', + ), + 1 => array(), + ))); + + $childType = new SecurityRolesType($this->roleBuilder); + + return array(new PreloadedExtension(array( + $childType->getName() => $childType, + ), array())); + } + + private function getSecurityRolesTypeName() + { + return + method_exists('Symfony\Component\Form\FormTypeInterface', 'setDefaultOptions') ? + 'sonata_security_roles' : + 'Sonata\UserBundle\Form\Type\SecurityRolesType'; + } } diff --git a/Tests/Menu/ProfileMenuBuilderTest.php b/Tests/Menu/ProfileMenuBuilderTest.php index 36144dfef..25a2c385d 100644 --- a/Tests/Menu/ProfileMenuBuilderTest.php +++ b/Tests/Menu/ProfileMenuBuilderTest.php @@ -1,7 +1,7 @@ * diff --git a/Tests/Resources/XliffTest.php b/Tests/Resources/XliffTest.php index 0c12bbb50..29f1def18 100644 --- a/Tests/Resources/XliffTest.php +++ b/Tests/Resources/XliffTest.php @@ -1,7 +1,7 @@ * diff --git a/Tests/Security/Authorization/Voter/UserAclVoterTest.php b/Tests/Security/Authorization/Voter/UserAclVoterTest.php index f8f4ce04d..c49dc4dad 100644 --- a/Tests/Security/Authorization/Voter/UserAclVoterTest.php +++ b/Tests/Security/Authorization/Voter/UserAclVoterTest.php @@ -1,7 +1,7 @@ * diff --git a/Tests/Security/EditableRolesBuilderTest.php b/Tests/Security/EditableRolesBuilderTest.php index af59447bf..ab4d94b63 100644 --- a/Tests/Security/EditableRolesBuilderTest.php +++ b/Tests/Security/EditableRolesBuilderTest.php @@ -1,7 +1,7 @@ * @@ -48,14 +48,14 @@ public function testRolesFromHierarchy() ); $expected = array( - 'ROLE_ADMIN' => 'ROLE_ADMIN: ROLE_USER', - 'ROLE_USER' => 'ROLE_USER', - 'ROLE_SUPER_ADMIN' => 'ROLE_SUPER_ADMIN: ROLE_USER, ROLE_SONATA_ADMIN, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH, ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT, ROLE_SONATA_PAGE_ADMIN_BLOCK_EDIT', - 'ROLE_SONATA_ADMIN' => 'ROLE_SONATA_ADMIN', - 'ROLE_ALLOWED_TO_SWITCH' => 'ROLE_ALLOWED_TO_SWITCH', - 'ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT' => 'ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT', + 'ROLE_ADMIN' => 'ROLE_ADMIN: ROLE_USER', + 'ROLE_USER' => 'ROLE_USER', + 'ROLE_SUPER_ADMIN' => 'ROLE_SUPER_ADMIN: ROLE_USER, ROLE_SONATA_ADMIN, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH, ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT, ROLE_SONATA_PAGE_ADMIN_BLOCK_EDIT', + 'ROLE_SONATA_ADMIN' => 'ROLE_SONATA_ADMIN', + 'ROLE_ALLOWED_TO_SWITCH' => 'ROLE_ALLOWED_TO_SWITCH', + 'ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT' => 'ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT', 'ROLE_SONATA_PAGE_ADMIN_BLOCK_EDIT' => 'ROLE_SONATA_PAGE_ADMIN_BLOCK_EDIT', - 'SONATA' => 'SONATA: ', + 'SONATA' => 'SONATA: ', ); $builder = new EditableRolesBuilder($security, $pool, $rolesHierarchy); @@ -91,10 +91,10 @@ public function testRolesFromAdminWithMasterAdmin() $builder = new EditableRolesBuilder($security, $pool, array()); $expected = array( - 'ROLE_FOO_GUEST' => 'ROLE_FOO_GUEST', - 'ROLE_FOO_STAFF' => 'ROLE_FOO_STAFF', + 'ROLE_FOO_GUEST' => 'ROLE_FOO_GUEST', + 'ROLE_FOO_STAFF' => 'ROLE_FOO_STAFF', 'ROLE_FOO_EDITOR' => 'ROLE_FOO_EDITOR', - 'ROLE_FOO_ADMIN' => 'ROLE_FOO_ADMIN', + 'ROLE_FOO_ADMIN' => 'ROLE_FOO_ADMIN', ); list($roles, $rolesReadOnly) = $builder->getRoles(); diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index f6cf0c362..cd5e8819c 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -1,11 +1,11 @@ + * (c) Thomas Rabaix * - * for the full copyright and license information, please view the LICENSE + * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/Twig/GlobalVariables.php b/Twig/GlobalVariables.php index fcf1c48f0..b3f6ac9e8 100644 --- a/Twig/GlobalVariables.php +++ b/Twig/GlobalVariables.php @@ -1,7 +1,7 @@ * From 39e32efce45cf8d4a247945f45145227fa481686 Mon Sep 17 00:00:00 2001 From: Sullivan SENECHAL Date: Fri, 13 May 2016 20:32:55 +0200 Subject: [PATCH 3/7] Add sllh/php-cs-fixer-styleci-bridge --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3f7937d54..1c856b47c 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "require-dev": { "sonata-project/seo-bundle": "^1.1", "doctrine/orm": "^2.0", - "symfony/phpunit-bridge": "^2.8 || ^3.0" + "symfony/phpunit-bridge": "^2.8 || ^3.0", + "sllh/php-cs-fixer-styleci-bridge": "^2.0" }, "suggest": { "sonata-project/doctrine-orm-admin-bundle": "^3.0", From 37ff64de1b900a86dd450223e6d932cf2ad1def1 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Tue, 17 May 2016 11:59:35 +0000 Subject: [PATCH 4/7] DevKit updates --- .github/PULL_REQUEST_TEMPLATE.md | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..4c3ada328 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,48 @@ + + + + +Closes # + +### Changelog + + + +```markdown +### Added +- Added some stuff + +### Changed + +### Deprecated + +### Removed + +### Fixed + +### Security +``` + +### Subject + + + +### To do + + + +- [ ] My PR stuff +- [ ] Update the tests +- [ ] Update the documentation +- [ ] Add an upgrade note From 40be21783e79897488b1489835f44f9fbaa53d87 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Tue, 17 May 2016 12:08:20 +0000 Subject: [PATCH 5/7] DevKit updates --- .github/ISSUE_TEMPLATE.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 87c36a44f..38e6b727e 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,8 +1,12 @@ -Delete this sentence after you read the "Issues" paragraph from the -"guidelines for contributing" link above. + -If you are reporting a bug, please try to fill in the following, otherwise -remove it along with this sentence. + | Question | Answer |----------------|------------------------------- From 33ee686e36584ad00aa3121923973cf2b9984787 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Tue, 17 May 2016 22:29:00 +0000 Subject: [PATCH 6/7] DevKit updates --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4c3ada328..06178306d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -17,7 +17,7 @@ Closes # ```markdown ### Added -- Added some stuff +- Added some `Class::newMethod` to do great stuff ### Changed @@ -32,7 +32,7 @@ Closes # ### Subject - + ### To do From 1ca382f749c306b4fe796d31c8bce35936ed8524 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Wed, 18 May 2016 06:02:59 +0000 Subject: [PATCH 7/7] DevKit updates --- CONTRIBUTING.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b8b662e35..7df6464f1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -130,6 +130,32 @@ Notes: * If your BC PR is accepted, you can do a new one on the `master` branch which remove the deprecated code. * SYMFONY DOC REF (same logic)? +If you have a non-BC PR to propose, please first try to create a related BC PR first. +This BC PR should mark every piece of code that needs to be removed / uncommented / reworked +in the corresponding non-BC PR with the following marker comment : `NEXT_MAJOR`. +When the BC PR is merged in the stable branch, wait for the stable branch to be +merged in the unstable branch, and then work on your non-BC PR. + +For instance, assuming you want to introduce a new method to an existing interface, you should do something like this: + +```php +