From eade32daf90471d9475822869f08c59fea2cc1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 15 Dec 2013 23:45:07 +0100 Subject: [PATCH] add user --- DependencyInjection/CLChillMainExtension.php | 25 +++++++++++++++- Entity/Agent.php | 2 +- Resources/config/routing.yml | 31 +++++++++++++++++++- Resources/views/layout.html.twig | 4 +-- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/DependencyInjection/CLChillMainExtension.php b/DependencyInjection/CLChillMainExtension.php index 82b4e68ec..04c3f5994 100644 --- a/DependencyInjection/CLChillMainExtension.php +++ b/DependencyInjection/CLChillMainExtension.php @@ -6,13 +6,14 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Loader; +use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; /** * This is the class that loads and manages your bundle configuration * * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} */ -class CLChillMainExtension extends Extension +class CLChillMainExtension extends Extension implements PrependExtensionInterface { /** * {@inheritDoc} @@ -25,4 +26,26 @@ class CLChillMainExtension extends Extension $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); } + + public function prepend(ContainerBuilder $container) { + $bundles = $container->getParameter('kernel.bundles'); + + //Configure FOSUSerBundle + if (!isset($bundles['FOSUserBundle'])) { + throw new MissingBundleException('FOSUserBundle'); + } + + $db_driver = array('db_driver' => 'orm'); + $container->prependExtensionConfig('fos_user', $db_driver); + + $user_class = array('user_class' => 'CL\Chill\MainBundle\Entity\Agent'); + $container->prependExtensionConfig('fos_user', $user_class); + + $registration_form = array('registration' => array( + 'form' => array('type' => 'chill_user_registration'))); + $container->prependExtensionConfig('fos_user', $registration_form); + + + } + } diff --git a/Entity/Agent.php b/Entity/Agent.php index 2aacd5064..da4891838 100644 --- a/Entity/Agent.php +++ b/Entity/Agent.php @@ -59,6 +59,6 @@ class Agent extends BaseUser { } public function __toString() { - parent::__toString(); + return parent::__toString(); } } diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 21146fa36..b5ef2073e 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,7 +1,36 @@ +root: + pattern: / + defaults: + _controller: FrameworkBundle:Redirect:urlRedirect + path: /hello + permanent: true + cl_chill_main_homepage: pattern: /hello defaults: { _controller: CLChillMainBundle:Default:index } chill_main_admin_central: pattern: /admin - defaults: { _controller: CLChillMainBundle:Admin:index } \ No newline at end of file + defaults: { _controller: CLChillMainBundle:Admin:index } + + +#load FosUserBundle + +fos_user_security: + resource: "@FOSUserBundle/Resources/config/routing/security.xml" + +fos_user_profile: + resource: "@FOSUserBundle/Resources/config/routing/profile.xml" + prefix: /profile + +fos_user_register: + resource: "@FOSUserBundle/Resources/config/routing/registration.xml" + prefix: /register + +fos_user_resetting: + resource: "@FOSUserBundle/Resources/config/routing/resetting.xml" + prefix: /resetting + +fos_user_change_password: + resource: "@FOSUserBundle/Resources/config/routing/change_password.xml" + prefix: /profile \ No newline at end of file diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index 775afebc0..6d1c5f6a0 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -54,11 +54,11 @@