Issues (3877)

DoubleSubmitProtectionServiceProvider.php (3 issues)

1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace Spryker\Shared\Application\ServiceProvider;
9
10
use Silex\Application;
11
use Silex\ServiceProviderInterface;
12
use Spryker\Shared\Symfony\Form\Extension\DoubleSubmitProtection\DoubleSubmitProtectionExtension;
13
use Spryker\Shared\Symfony\Form\Extension\DoubleSubmitProtection\RequestTokenProvider\SessionStorage;
14
use Spryker\Shared\Symfony\Form\Extension\DoubleSubmitProtection\RequestTokenProvider\TokenHashGenerator;
15
use Spryker\Zed\Kernel\Communication\AbstractPlugin;
16
17
/**
18
 * @deprecated Use {@link \Spryker\Zed\Form\Communication\Plugin\Form\DoubleSubmitProtectionFormPlugin} instead.
19
 */
20
class DoubleSubmitProtectionServiceProvider extends AbstractPlugin implements ServiceProviderInterface
21
{
22
    /**
23
     * @param \Silex\Application $app
24
     *
25
     * @return void
26
     */
27
    public function register(Application $app)
28
    {
29
        $app['form.extension.double_submit_protection'] = $app->share(function ($app) {
30
            $translator = $app['translator'] ?? null;
31
32
            return $this->createDoubleSubmitProtectionExtension($app, $translator);
33
        });
34
35
        $app->extend('form.extensions', function ($extensions) use ($app) {
36
            $extensions[] = $app['form.extension.double_submit_protection'];
37
38
            return $extensions;
39
        });
40
    }
41
42
    /**
43
     * @return \Spryker\Shared\Symfony\Form\Extension\DoubleSubmitProtection\RequestTokenProvider\TokenHashGenerator
44
     */
45
    protected function createTokenGenerator()
46
    {
47
        return new TokenHashGenerator();
0 ignored issues
show
Deprecated Code introduced by
The class Spryker\Shared\Symfony\F...ider\TokenHashGenerator has been deprecated: Use {@link \Spryker\Shared\Form\DoubleSubmitProtection\RequestTokenProvider\TokenHashGenerator} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

47
        return /** @scrutinizer ignore-deprecated */ new TokenHashGenerator();
Loading history...
48
    }
49
50
    /**
51
     * @param \Silex\Application $app
52
     *
53
     * @return \Spryker\Shared\Symfony\Form\Extension\DoubleSubmitProtection\RequestTokenProvider\SessionStorage
54
     */
55
    protected function createTokenStorage(Application $app)
56
    {
57
        return new SessionStorage($app['session']);
0 ignored issues
show
Deprecated Code introduced by
The class Spryker\Shared\Symfony\F...Provider\SessionStorage has been deprecated: Use {@link \Spryker\Shared\Form\DoubleSubmitProtection\RequestTokenProvider\SessionStorage} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

57
        return /** @scrutinizer ignore-deprecated */ new SessionStorage($app['session']);
Loading history...
58
    }
59
60
    /**
61
     * @param \Silex\Application $app
62
     * @param \Symfony\Contracts\Translation\TranslatorInterface|null $translator
63
     *
64
     * @return \Spryker\Shared\Symfony\Form\Extension\DoubleSubmitProtection\DoubleSubmitProtectionExtension
65
     */
66
    protected function createDoubleSubmitProtectionExtension(Application $app, $translator = null)
67
    {
68
        return new DoubleSubmitProtectionExtension(
0 ignored issues
show
Deprecated Code introduced by
The class Spryker\Shared\Symfony\F...bmitProtectionExtension has been deprecated: Use {@link \Spryker\Shared\Form\DoubleSubmitProtection\DoubleSubmitProtectionExtension} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

68
        return /** @scrutinizer ignore-deprecated */ new DoubleSubmitProtectionExtension(
Loading history...
69
            $this->createTokenGenerator(),
70
            $this->createTokenStorage($app),
71
            $translator,
72
        );
73
    }
74
75
    /**
76
     * @param \Silex\Application $app
77
     *
78
     * @return void
79
     */
80
    public function boot(Application $app)
81
    {
82
    }
83
}
84