SecretStep.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 Sensio\Bundle\DistributionBundle\Configurator\Step;
  11. use Sensio\Bundle\DistributionBundle\Configurator\Form\SecretStepType;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14. * Secret Step.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. */
  18. class SecretStep implements StepInterface
  19. {
  20. /**
  21. * @Assert\NotBlank
  22. */
  23. public $secret;
  24. public function __construct(array $parameters)
  25. {
  26. $this->secret = $parameters['secret'];
  27. if ('ThisTokenIsNotSoSecretChangeIt' == $this->secret) {
  28. $this->secret = hash('sha1', uniqid(mt_rand()));
  29. }
  30. }
  31. /**
  32. * @see StepInterface
  33. */
  34. public function getFormType()
  35. {
  36. return new SecretStepType();
  37. }
  38. /**
  39. * @see StepInterface
  40. */
  41. public function checkRequirements()
  42. {
  43. return array();
  44. }
  45. /**
  46. * checkOptionalSettings
  47. */
  48. public function checkOptionalSettings()
  49. {
  50. return array();
  51. }
  52. /**
  53. * @see StepInterface
  54. */
  55. public function update(StepInterface $data)
  56. {
  57. return array('secret' => $data->secret);
  58. }
  59. /**
  60. * @see StepInterface
  61. */
  62. public function getTemplate()
  63. {
  64. return 'SensioDistributionBundle:Configurator/Step:secret.html.twig';
  65. }
  66. }