|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Symfony package. |
|
|
5 |
* |
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
7 |
* |
|
|
8 |
* For the full copyright and license information, please view the LICENSE |
|
|
9 |
* file that was distributed with this source code. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Sensio\Bundle\DistributionBundle\Configurator\Step; |
|
|
13 |
|
|
|
14 |
use Sensio\Bundle\DistributionBundle\Configurator\Form\SecretStepType; |
|
|
15 |
use Symfony\Component\Validator\Constraints as Assert; |
|
|
16 |
|
|
|
17 |
/** |
|
|
18 |
* Secret Step. |
|
|
19 |
* |
|
|
20 |
* @author Fabien Potencier <fabien@symfony.com> |
|
|
21 |
*/ |
|
|
22 |
class SecretStep implements StepInterface |
|
|
23 |
{ |
|
|
24 |
/** |
|
|
25 |
* @Assert\NotBlank |
|
|
26 |
*/ |
|
|
27 |
public $secret; |
|
|
28 |
|
|
|
29 |
public function __construct(array $parameters) |
|
|
30 |
{ |
|
|
31 |
$this->secret = $parameters['secret']; |
|
|
32 |
|
|
|
33 |
if ('ThisTokenIsNotSoSecretChangeIt' == $this->secret) { |
|
|
34 |
$this->secret = hash('sha1', uniqid(mt_rand())); |
|
|
35 |
} |
|
|
36 |
} |
|
|
37 |
|
|
|
38 |
/** |
|
|
39 |
* @see StepInterface |
|
|
40 |
*/ |
|
|
41 |
public function getFormType() |
|
|
42 |
{ |
|
|
43 |
return new SecretStepType(); |
|
|
44 |
} |
|
|
45 |
|
|
|
46 |
/** |
|
|
47 |
* @see StepInterface |
|
|
48 |
*/ |
|
|
49 |
public function checkRequirements() |
|
|
50 |
{ |
|
|
51 |
return array(); |
|
|
52 |
} |
|
|
53 |
|
|
|
54 |
/** |
|
|
55 |
* checkOptionalSettings |
|
|
56 |
*/ |
|
|
57 |
public function checkOptionalSettings() |
|
|
58 |
{ |
|
|
59 |
return array(); |
|
|
60 |
} |
|
|
61 |
|
|
|
62 |
/** |
|
|
63 |
* @see StepInterface |
|
|
64 |
*/ |
|
|
65 |
public function update(StepInterface $data) |
|
|
66 |
{ |
|
|
67 |
return array('secret' => $data->secret); |
|
|
68 |
} |
|
|
69 |
|
|
|
70 |
/** |
|
|
71 |
* @see StepInterface |
|
|
72 |
*/ |
|
|
73 |
public function getTemplate() |
|
|
74 |
{ |
|
|
75 |
return 'SensioDistributionBundle:Configurator/Step:secret.html.twig'; |
|
|
76 |
} |
|
|
77 |
} |