From 9b9eb2ff6979d9de47f828002c31363940d2512d Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Mon, 28 Mar 2011 19:03:28 +0200 Subject: [PATCH] Updated for the framework change --- Controller/GroupController.php | 12 +++---- Controller/SecurityController.php | 2 +- Controller/UserController.php | 30 ++++++++-------- DependencyInjection/Configuration.php | 4 +-- Resources/doc/index.rst | 35 ++++++++----------- Resources/views/Group/edit.html.twig | 4 +-- Resources/views/Group/list.html.twig | 4 +-- Resources/views/Group/new.html.twig | 4 +-- Resources/views/Group/show.html.twig | 4 +-- Resources/views/Security/login.html.twig | 2 +- Resources/views/User/changePassword.html.twig | 4 +-- .../views/User/checkResettingEmail.html.twig | 2 +- Resources/views/User/edit.html.twig | 4 +-- Resources/views/User/list.html.twig | 4 +-- Resources/views/User/new.html.twig | 4 +-- .../User/passwordAlreadyRequested.html.twig | 2 +- .../views/User/requestResetPassword.html.twig | 4 +-- Resources/views/User/resetPassword.html.twig | 4 +-- Resources/views/User/show.html.twig | 4 +-- .../FOSUserExtensionTest.php | 4 +-- 20 files changed, 66 insertions(+), 71 deletions(-) diff --git a/Controller/GroupController.php b/Controller/GroupController.php index c5098f73b2..4c2a3d8653 100644 --- a/Controller/GroupController.php +++ b/Controller/GroupController.php @@ -27,7 +27,7 @@ public function listAction() { $groups = $this->container->get('fos_user.group_manager')->findGroups(); - return $this->container->get('templating')->renderResponse('FOSUserBundle:Group:list.html.'.$this->getEngine(), array('groups' => $groups)); + return $this->container->get('templating')->renderResponse('FOSUser:Group:list.html.'.$this->getEngine(), array('groups' => $groups)); } /** @@ -37,7 +37,7 @@ public function showAction($groupname) { $group = $this->findGroupBy('name', $groupname); - return $this->container->get('templating')->renderResponse('FOSUserBundle:Group:show.html.'.$this->getEngine(), array('group' => $group)); + return $this->container->get('templating')->renderResponse('FOSUser:Group:show.html.'.$this->getEngine(), array('group' => $group)); } /** @@ -50,7 +50,7 @@ public function editAction($groupname) $form->process($group); - return $this->container->get('templating')->renderResponse('FOSUserBundle:Group:edit.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:Group:edit.html.'.$this->getEngine(), array( 'form' => $form, 'groupname' => $group->getName() )); @@ -71,7 +71,7 @@ public function updateAction($groupname) return new RedirectResponse($groupUrl); } - return $this->container->get('templating')->renderResponse('FOSUserBundle:Group:edit.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:Group:edit.html.'.$this->getEngine(), array( 'form' => $form, 'groupname' => $group->getName() )); @@ -86,7 +86,7 @@ public function newAction() $form->process(); - return $this->container->get('templating')->renderResponse('FOSUserBundle:Group:new.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:Group:new.html.'.$this->getEngine(), array( 'form' => $form )); } @@ -106,7 +106,7 @@ public function createAction() return new RedirectResponse($url); } - return $this->container->get('templating')->renderResponse('FOSUserBundle:Group:new.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:Group:new.html.'.$this->getEngine(), array( 'form' => $form )); } diff --git a/Controller/SecurityController.php b/Controller/SecurityController.php index 5eb303a0cf..bec75f8909 100644 --- a/Controller/SecurityController.php +++ b/Controller/SecurityController.php @@ -23,7 +23,7 @@ public function loginAction() $error = $error->getMessage(); } - return $this->container->get('templating')->renderResponse('FOSUserBundle:Security:login.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:Security:login.html.'.$this->getEngine(), array( // last username entered by the user 'last_username' => $this->container->get('request')->getSession()->get(SecurityContext::LAST_USERNAME), 'error' => $error, diff --git a/Controller/UserController.php b/Controller/UserController.php index f3a994574b..d12ad18bb1 100644 --- a/Controller/UserController.php +++ b/Controller/UserController.php @@ -33,7 +33,7 @@ public function listAction() { $users = $this->container->get('fos_user.user_manager')->findUsers(); - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:list.html.'.$this->getEngine(), array('users' => $users)); + return $this->container->get('templating')->renderResponse('FOSUser:User:list.html.'.$this->getEngine(), array('users' => $users)); } /** @@ -42,7 +42,7 @@ public function listAction() public function showAction($username) { $user = $this->findUserBy('username', $username); - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:show.html.'.$this->getEngine(), array('user' => $user)); + return $this->container->get('templating')->renderResponse('FOSUser:User:show.html.'.$this->getEngine(), array('user' => $user)); } /** @@ -55,7 +55,7 @@ public function editAction($username) $form->process($user); - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:edit.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:User:edit.html.'.$this->getEngine(), array( 'form' => $form, 'username' => $user->getUsername() )); @@ -76,7 +76,7 @@ public function updateAction($username) return new RedirectResponse($userUrl); } - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:edit.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:User:edit.html.'.$this->getEngine(), array( 'form' => $form, 'username' => $user->getUsername() )); @@ -91,7 +91,7 @@ public function newAction() $form->process(); - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:new.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:User:new.html.'.$this->getEngine(), array( 'form' => $form )); } @@ -129,7 +129,7 @@ public function createAction() return new RedirectResponse($url); } - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:new.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:User:new.html.'.$this->getEngine(), array( 'form' => $form )); } @@ -145,7 +145,7 @@ public function checkConfirmationEmailAction() $this->setFlash('fos_user_user_confirm', 'success'); - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:checkConfirmationEmail.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:User:checkConfirmationEmail.html.'.$this->getEngine(), array( 'user' => $user, )); } @@ -173,7 +173,7 @@ public function confirmedAction() $user = $this->getUser(); $this->setFlash('fos_user_user_confirmed', 'success'); - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:confirmed.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:User:confirmed.html.'.$this->getEngine(), array( 'user' => $user, )); } @@ -199,7 +199,7 @@ public function changePasswordAction() $form = $this->container->get('fos_user.form.change_password'); $form->process($user); - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:changePassword.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:User:changePassword.html.'.$this->getEngine(), array( 'form' => $form )); } @@ -219,7 +219,7 @@ public function changePasswordUpdateAction() return new RedirectResponse($url); } - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:changePassword.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:User:changePassword.html.'.$this->getEngine(), array( 'form' => $form )); } @@ -229,7 +229,7 @@ public function changePasswordUpdateAction() */ public function requestResetPasswordAction() { - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:requestResetPassword.html.'.$this->getEngine()); + return $this->container->get('templating')->renderResponse('FOSUser:User:requestResetPassword.html.'.$this->getEngine()); } /** @@ -240,7 +240,7 @@ public function sendResettingEmailAction() $user = $this->findUserBy('username', $this->container->get('request')->get('username')); if ($user->isPasswordRequestNonExpired($this->getPasswordRequestTtl())) { - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:passwordAlreadyRequested.html.'.$this->getEngine()); + return $this->container->get('templating')->renderResponse('FOSUser:User:passwordAlreadyRequested.html.'.$this->getEngine()); } $user->generateConfirmationToken(); @@ -266,7 +266,7 @@ public function checkResettingEmailAction() $this->setFlash('fos_user_user_reset', 'success'); - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:checkResettingEmail.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:User:checkResettingEmail.html.'.$this->getEngine(), array( 'user' => $user, )); } @@ -285,7 +285,7 @@ public function resetPasswordAction($token) $form = $this->container->get('fos_user.form.reset_password'); $form->process($user); - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:resetPassword.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:User:resetPassword.html.'.$this->getEngine(), array( 'token' => $token, 'form' => $form )); @@ -313,7 +313,7 @@ public function resetPasswordUpdateAction($token) return new RedirectResponse($url); } - return $this->container->get('templating')->renderResponse('FOSUserBundle:User:resetPassword.html.'.$this->getEngine(), array( + return $this->container->get('templating')->renderResponse('FOSUser:User:resetPassword.html.'.$this->getEngine(), array( 'token' => $token, 'form' => $form )); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 0b8f7b81aa..96384489cf 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -188,13 +188,13 @@ private function addEmailSection(ArrayNodeDefinition $node) ->addDefaultsIfNotSet() ->children() ->booleanNode('enabled')->defaultFalse()->end() - ->scalarNode('template')->defaultValue('FOSUserBundle:User:confirmationEmail')->end() + ->scalarNode('template')->defaultValue('FOSUser:User:confirmationEmail')->end() ->end() ->end() ->arrayNode('resetting_password') ->addDefaultsIfNotSet() ->children() - ->scalarNode('template')->defaultValue('FOSUserBundle:User:resettingPasswordEmail')->end() + ->scalarNode('template')->defaultValue('FOSUser:User:resettingPasswordEmail')->end() ->scalarNode('token_ttl')->defaultValue(86400)->end() ->end() ->end() diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 40148329c9..f8bad30b17 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -148,8 +148,8 @@ along with the bundle containing your custom User class:: doctrine: orm: mappings: - FOSUserBundle: ~ - MyProjectMyBundle: ~ + FOSUser: ~ + MyProjectMy: ~ # your other bundles The above example assumes an ORM configuration, but the ``mappings`` @@ -253,18 +253,18 @@ routes: # app/config/routing.yml fos_user_security: - resource: @FOSUserBundle/Resources/config/routing/security.xml + resource: @FOSUser/Resources/config/routing/security.xml fos_user_user: - resource: @FOSUserBundle/Resources/config/routing/user.xml + resource: @FOSUser/Resources/config/routing/user.xml prefix: /user :: # app/config/routing.xml - - + + You now can login at http://app.com/login @@ -578,20 +578,14 @@ Templating ---------- The template names are not configurable, however Symfony2 makes it possible -to extend a bundle by creating a new Bundle and implementing a getParent() -method inside that new Bundle's definition:: - - class MyProjectUserBundle extends Bundle - { - public function getParent() - { - return 'FOSUserBundle'; - } - } +to extend a bundle by defining a template in the app/ directory. For example ``vendor/bundles/FOS/UserBundle/Resources/views/User/new.twig`` can be replaced inside an application by putting a file with alternative content in -``src/MyProject/UserBundle/Resources/views/User/new.twig``. +``app/Resources/FOSUser/views/User/new.twig``. + +You could also create a bundle defined as child of FOSUserBundle and placing the +templates in it. You can use a different templating engine by configuring it but you will have to create all the needed templates as only twig templates are provided. @@ -621,9 +615,10 @@ Canonicalization ---------------- ``Canonicalizer`` services are used to canonicalize the username and the email -fields for database storage. By default, username and email fields are canonicalized -in the same manner using ``mb_convert_case()``. You may configure your own class -for each field provided it implements ``FOS\UserBundle\Util\CanonicalizerInterface``. +fields for database storage. By default, username and email fields are +canonicalized in the same manner using ``mb_convert_case()``. You may configure +your own class for each field provided it implements +``FOS\UserBundle\Util\CanonicalizerInterface``. Note:: diff --git a/Resources/views/Group/edit.html.twig b/Resources/views/Group/edit.html.twig index a94db9b4da..6c9a3075a0 100644 --- a/Resources/views/Group/edit.html.twig +++ b/Resources/views/Group/edit.html.twig @@ -1,5 +1,5 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} -{% include "FOSUserBundle:Group:edit_content.html.twig" %} +{% include "FOSUser:Group:edit_content.html.twig" %} {% endblock content %} diff --git a/Resources/views/Group/list.html.twig b/Resources/views/Group/list.html.twig index 12e30c4171..28447e24df 100644 --- a/Resources/views/Group/list.html.twig +++ b/Resources/views/Group/list.html.twig @@ -1,5 +1,5 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} -{% include "FOSUserBundle:Group:list_content.html.twig" %} +{% include "FOSUser:Group:list_content.html.twig" %} {% endblock content %} diff --git a/Resources/views/Group/new.html.twig b/Resources/views/Group/new.html.twig index cfb691272f..5927dfc720 100644 --- a/Resources/views/Group/new.html.twig +++ b/Resources/views/Group/new.html.twig @@ -1,5 +1,5 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} -{% include "FOSUserBundle:Group:new_content.html.twig" %} +{% include "FOSUser:Group:new_content.html.twig" %} {% endblock content %} diff --git a/Resources/views/Group/show.html.twig b/Resources/views/Group/show.html.twig index ac33936c30..5b0f1b26e3 100644 --- a/Resources/views/Group/show.html.twig +++ b/Resources/views/Group/show.html.twig @@ -1,5 +1,5 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} -{% include "FOSUserBundle:Group:show_content.html.twig" %} +{% include "FOSUser:Group:show_content.html.twig" %} {% endblock content %} diff --git a/Resources/views/Security/login.html.twig b/Resources/views/Security/login.html.twig index ef1d29c850..ee25bae4c2 100644 --- a/Resources/views/Security/login.html.twig +++ b/Resources/views/Security/login.html.twig @@ -1,4 +1,4 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} {% if error %} diff --git a/Resources/views/User/changePassword.html.twig b/Resources/views/User/changePassword.html.twig index 9a7f7eb9dc..9d0d80661b 100644 --- a/Resources/views/User/changePassword.html.twig +++ b/Resources/views/User/changePassword.html.twig @@ -1,5 +1,5 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} -{% include "FOSUserBundle:User:changePassword_content.html.twig" %} +{% include "FOSUser:User:changePassword_content.html.twig" %} {% endblock content %} diff --git a/Resources/views/User/checkResettingEmail.html.twig b/Resources/views/User/checkResettingEmail.html.twig index 0528b5f2ff..f51012861d 100644 --- a/Resources/views/User/checkResettingEmail.html.twig +++ b/Resources/views/User/checkResettingEmail.html.twig @@ -1,4 +1,4 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} {% set email = user.getEmail() %} diff --git a/Resources/views/User/edit.html.twig b/Resources/views/User/edit.html.twig index 170c499155..3c75b929d4 100644 --- a/Resources/views/User/edit.html.twig +++ b/Resources/views/User/edit.html.twig @@ -1,5 +1,5 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} -{% include "FOSUserBundle:User:edit_content.html.twig" %} +{% include "FOSUser:User:edit_content.html.twig" %} {% endblock content %} diff --git a/Resources/views/User/list.html.twig b/Resources/views/User/list.html.twig index d93ecf8964..b6e2e0c644 100644 --- a/Resources/views/User/list.html.twig +++ b/Resources/views/User/list.html.twig @@ -1,5 +1,5 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} -{% include "FOSUserBundle:User:list_content.html.twig" %} +{% include "FOSUser:User:list_content.html.twig" %} {% endblock content %} diff --git a/Resources/views/User/new.html.twig b/Resources/views/User/new.html.twig index 06b2c36a43..33a9fafb04 100644 --- a/Resources/views/User/new.html.twig +++ b/Resources/views/User/new.html.twig @@ -1,5 +1,5 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} -{% include "FOSUserBundle:User:new_content.html.twig" %} +{% include "FOSUser:User:new_content.html.twig" %} {% endblock content %} diff --git a/Resources/views/User/passwordAlreadyRequested.html.twig b/Resources/views/User/passwordAlreadyRequested.html.twig index b0a45bea4f..3960dad611 100644 --- a/Resources/views/User/passwordAlreadyRequested.html.twig +++ b/Resources/views/User/passwordAlreadyRequested.html.twig @@ -1,4 +1,4 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} The password for this user has already been requested within the last 24 hours. diff --git a/Resources/views/User/requestResetPassword.html.twig b/Resources/views/User/requestResetPassword.html.twig index a459505418..0d892c9a0e 100644 --- a/Resources/views/User/requestResetPassword.html.twig +++ b/Resources/views/User/requestResetPassword.html.twig @@ -1,5 +1,5 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} -{% include "FOSUserBundle:User:requestResetPassword_content.html.twig" %} +{% include "FOSUser:User:requestResetPassword_content.html.twig" %} {% endblock content %} diff --git a/Resources/views/User/resetPassword.html.twig b/Resources/views/User/resetPassword.html.twig index a1dce38729..bc8ad365ef 100644 --- a/Resources/views/User/resetPassword.html.twig +++ b/Resources/views/User/resetPassword.html.twig @@ -1,5 +1,5 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} -{% include "FOSUserBundle:User:resetPassword_content.html.twig" %} +{% include "FOSUser:User:resetPassword_content.html.twig" %} {% endblock content %} diff --git a/Resources/views/User/show.html.twig b/Resources/views/User/show.html.twig index 34aa601b9f..9676afaf40 100644 --- a/Resources/views/User/show.html.twig +++ b/Resources/views/User/show.html.twig @@ -1,5 +1,5 @@ -{% extends "FOSUserBundle::layout.html.twig" %} +{% extends "FOSUser::layout.html.twig" %} {% block content %} -{% include "FOSUserBundle:User:show_content.html.twig" %} +{% include "FOSUser:User:show_content.html.twig" %} {% endblock content %} diff --git a/Tests/DependencyInjection/FOSUserExtensionTest.php b/Tests/DependencyInjection/FOSUserExtensionTest.php index 32f281c2c6..d5c24da230 100644 --- a/Tests/DependencyInjection/FOSUserExtensionTest.php +++ b/Tests/DependencyInjection/FOSUserExtensionTest.php @@ -190,8 +190,8 @@ public function testUserLoadConfirmationEmailWithDefaults() $this->assertParameter(false, 'fos_user.email.confirmation.enabled'); $this->assertParameter(array('webmaster@example.com' => 'webmaster'), 'fos_user.email.from_email'); - $this->assertParameter('FOSUserBundle:User:confirmationEmail', 'fos_user.email.confirmation.template'); - $this->assertParameter('FOSUserBundle:User:resettingPasswordEmail', 'fos_user.email.resetting_password.template'); + $this->assertParameter('FOSUser:User:confirmationEmail', 'fos_user.email.confirmation.template'); + $this->assertParameter('FOSUser:User:resettingPasswordEmail', 'fos_user.email.resetting_password.template'); $this->assertParameter(86400, 'fos_user.email.resetting_password.token_ttl'); }