-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved account recovery features to it's bundle #797
- Loading branch information
1 parent
8135396
commit e64f527
Showing
13 changed files
with
256 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/LoginCidadao/AccountRecoveryBundle/Controller/AccountRecoveryDataController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace LoginCidadao\AccountRecoveryBundle\Controller; | ||
|
||
use LoginCidadao\AccountRecoveryBundle\Form\AccountRecoveryDataType; | ||
use LoginCidadao\CoreBundle\Model\PersonInterface; | ||
use LoginCidadao\AccountRecoveryBundle\Service\AccountRecoveryService; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class AccountRecoveryDataController extends Controller | ||
{ | ||
/** | ||
* @Route("/account-recovery-data") | ||
* @Template() | ||
*/ | ||
public function editAction(Request $request) | ||
{ | ||
/** @var PersonInterface $person */ | ||
$person = $this->getUser(); | ||
|
||
/** @var AccountRecoveryService $accountRecoveryService */ | ||
$accountRecoveryService = $this->get('lc.account_recovery'); | ||
|
||
$recoveryData = $accountRecoveryService->getAccountRecoveryData($person); | ||
$form = $this->createForm(AccountRecoveryDataType::class, $recoveryData); | ||
$form->handleRequest($request); | ||
if ($form->isValid()) { | ||
$this->getDoctrine()->getManager()->flush(); | ||
} | ||
|
||
return [ | ||
'form' => $form->createView(), | ||
]; | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/LoginCidadao/AccountRecoveryBundle/DependencyInjection/Configuration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace LoginCidadao\AccountRecoveryBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
/** | ||
* This is the class that validates and merges configuration from your app/config files | ||
* | ||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('login_cidadao_account_recovery'); | ||
|
||
// Here you should define the parameters that are allowed to | ||
// configure your bundle. See the documentation linked above for | ||
// more information on that topic. | ||
|
||
return $treeBuilder; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...idadao/AccountRecoveryBundle/DependencyInjection/LoginCidadaoAccountRecoveryExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace LoginCidadao\AccountRecoveryBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
|
||
/** | ||
* 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 LoginCidadaoAccountRecoveryExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$configuration = new Configuration(); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | ||
$loader->load('services.yml'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/LoginCidadao/AccountRecoveryBundle/Form/AccountRecoveryDataType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace LoginCidadao\AccountRecoveryBundle\Form; | ||
|
||
use libphonenumber\PhoneNumberFormat; | ||
use LoginCidadao\AccountRecoveryBundle\Entity\AccountRecoveryData; | ||
use Misd\PhoneNumberBundle\Form\Type\PhoneNumberType; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\EmailType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class AccountRecoveryDataType extends AbstractType | ||
{ | ||
/** | ||
* @param FormBuilderInterface $builder | ||
* @param array $options | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
$builder | ||
->add('email', EmailType::class) | ||
->add('mobile', PhoneNumberType::class, | ||
[ | ||
'required' => false, | ||
'label' => 'person.form.mobile.label', | ||
'attr' => [ | ||
'class' => 'form-control intl-tel', | ||
'placeholder' => 'person.form.mobile.placeholder', | ||
], | ||
'label_attr' => ['class' => 'intl-tel-label'], | ||
'format' => PhoneNumberFormat::E164, | ||
]); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function configureOptions(OptionsResolver $resolver) | ||
{ | ||
$resolver->setDefaults([ | ||
'data_class' => AccountRecoveryData::class, | ||
]); | ||
} | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return 'accrecoverydata'; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/LoginCidadao/AccountRecoveryBundle/LoginCidadaoAccountRecoveryBundle.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace LoginCidadao\AccountRecoveryBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class LoginCidadaoAccountRecoveryBundle extends Bundle | ||
{ | ||
} |
4 changes: 4 additions & 0 deletions
4
src/LoginCidadao/AccountRecoveryBundle/Resources/config/routing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lc_account_recovery: | ||
resource: "@LoginCidadaoAccountRecoveryBundle/Controller/" | ||
type: annotation | ||
prefix: / |
14 changes: 14 additions & 0 deletions
14
src/LoginCidadao/AccountRecoveryBundle/Resources/config/services.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
parameters: | ||
|
||
services: | ||
lc.account_recovery.repository: | ||
class: Doctrine\ORM\EntityRepository | ||
factory: ["@doctrine.orm.entity_manager", getRepository] | ||
arguments: | ||
- LoginCidadao\AccountRecoveryBundle\Entity\AccountRecoveryData | ||
|
||
lc.account_recovery: | ||
class: LoginCidadao\AccountRecoveryBundle\Service\AccountRecoveryService | ||
arguments: | ||
- "@doctrine.orm.entity_manager" | ||
- "@lc.account_recovery.repository" |
Oops, something went wrong.