CsrfStep.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\WebConfiguratorBundle\Step;
  11. use Symfony\Component\Form\FormContext;
  12. use Symfony\Bundle\WebConfiguratorBundle\Form\CsrfForm;
  13. use Symfony\Bundle\WebConfiguratorBundle\Exception\StepRequirementException;
  14. /**
  15. * Csrf Step.
  16. *
  17. * @author Fabien Potencier <fabien@symfony.com>
  18. */
  19. class CsrfStep implements StepInterface
  20. {
  21. /**
  22. * @validation:NotBlank
  23. */
  24. public $csrf_secret;
  25. public function __construct(array $parameters)
  26. {
  27. $this->csrf_secret = $parameters['csrf_secret'];
  28. }
  29. /**
  30. * @see StepInterface
  31. */
  32. public function getForm(FormContext $context)
  33. {
  34. return CsrfForm::create($context, 'config');
  35. }
  36. /**
  37. * @see StepInterface
  38. */
  39. public function checkRequirements()
  40. {
  41. return array();
  42. }
  43. /**
  44. * checkOptionalSettings
  45. */
  46. public function checkOptionalSettings()
  47. {
  48. return array();
  49. }
  50. /**
  51. * @see StepInterface
  52. */
  53. public function update(StepInterface $data)
  54. {
  55. return array('csrf_secret' => $data->csrf_secret);
  56. }
  57. /**
  58. * @see StepInterface
  59. */
  60. public function getTemplate()
  61. {
  62. return 'SymfonyWebConfigurator:Step:csrf.html.twig';
  63. }
  64. }