Completed
Push — develop ( f8651f...893e32 )
by greg
02:30
created

Memory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 54
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 51 1
1
<?php
2
3
namespace PlaygroundGame\Form\Admin;
4
5
use PlaygroundCore\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator;
6
use Zend\Mvc\I18n\Translator;
7
use Zend\ServiceManager\ServiceManager;
8
9
class Memory extends Game
10
{
11
    public function __construct($name, ServiceManager $sm, Translator $translator)
12
    {
13
        $this->setServiceManager($sm);
14
        $entityManager = $sm->get('doctrine.entitymanager.orm_default');
15
16
        // having to fix a Doctrine-module bug :( https://github.com/doctrine/DoctrineModule/issues/180
17
        $hydrator = new DoctrineHydrator($entityManager, 'PlaygroundGame\Entity\Memory');
18
        $hydrator->addStrategy('partner', new \PlaygroundCore\Stdlib\Hydrator\Strategy\ObjectStrategy());
19
        $this->setHydrator($hydrator);
20
21
        parent::__construct($name, $sm, $translator);
22
23
        $this->add(array(
24
            'name' => 'victoryConditions',
25
            'type' => 'Zend\Form\Element\Text',
26
            'attributes' => array(
27
                'placeholder' => $translator->translate('% good picks vs mistakes', 'playgroundgame'),
28
                'id' => 'victoryConditions',
29
            ),
30
            'options' => array(
31
                'label' => $translator->translate('Victory conditions', 'playgroundgame'),
32
            ),
33
        ));
34
35
        // Adding an empty upload field to be able to correctly handle this on
36
        // the service side.
37
        $this->add(array(
38
            'name' => 'uploadBackImage',
39
            'attributes' => array(
40
                'type' => 'file',
41
            ),
42
            'options' => array(
43
                'label' => $translator->translate('Back card image', 'playgroundgame'),
44
            ),
45
        ));
46
        $this->add(array(
47
                'name' => 'backImage',
48
                'type' => 'Zend\Form\Element\Hidden',
49
                'attributes' => array(
50
                    'value' => '',
51
                ),
52
        ));
53
        $this->add(array(
54
            'name' => 'deleteBackImage',
55
            'type' => 'Zend\Form\Element\Hidden',
56
            'attributes' => array(
57
                'value' => '',
58
                'class' => 'delete_scratch_image',
59
            ),
60
        ));
61
    }
62
}
63