Completed
Push — development ( deb2fc...28a639 )
by Torben
04:28 queued 25s
created

HmacViewHelper::injectHashService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace DERHANSEN\SfEventMgt\ViewHelpers\Registration;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
18
19
/**
20
 * Hmac ViewHelper for registrations
21
 *
22
 * @author Torben Hansen <[email protected]>
23
 */
24
class HmacViewHelper extends AbstractViewHelper
25
{
26
    /**
27
     * Hash Service
28
     *
29
     * @var \TYPO3\CMS\Extbase\Security\Cryptography\HashService
30
     * */
31
    protected $hashService;
32
33
    /**
34
     * DI for $hashService
35
     *
36
     * @param \TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService
37
     */
38
    public function injectHashService(\TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService)
39
    {
40
        $this->hashService = $hashService;
41
    }
42
43
    /**
44
     * Returns the hmac for the given registration in order to cancel the registration
45
     *
46
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
47
     *
48
     * @return string
49
     */
50
    public function render($registration)
51
    {
52
        $result = '';
53
        if ($registration) {
54
            $result = $this->hashService->generateHmac('reg-' . $registration->getUid());
55
        }
56
        return $result;
57
    }
58
}
59