GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 6a2c5a...d705f7 )
by Shane
03:05 queued 03:01
created

GeneratorAssembler::setCodeGenerators()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 47
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 47
rs 9.0303
cc 1
eloc 31
nc 1
nop 1
1
<?php
2
/**
3
 * MageSpec
4
 *
5
 * NOTICE OF LICENSE
6
 *
7
 * This source file is subject to the MIT License, that is bundled with this
8
 * package in the file LICENSE.
9
 * It is also available through the world-wide-web at this URL:
10
 *
11
 * http://opensource.org/licenses/MIT
12
 *
13
 * If you did not receive a copy of the license and are unable to obtain it
14
 * through the world-wide-web, please send an email
15
 * to <[email protected]> so we can send you a copy immediately.
16
 *
17
 * @category   MageTest
18
 * @package    PhpSpec_MagentoExtension
19
 *
20
 * @copyright  Copyright (c) 2012-2013 MageTest team and contributors.
21
 */
22
namespace MageTest\PhpSpec\MagentoExtension\Extension;
23
24
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\BlockGenerator;
25
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\ControllerGenerator;
26
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\ControllerSpecificationGenerator;
27
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\HelperGenerator;
28
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\ModelGenerator;
29
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\Xml\ConfigGenerator;
30
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\Xml\Element\BlockElement;
31
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\Xml\Element\ControllerElement;
32
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\Xml\Element\HelperElement;
33
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\Xml\Element\ModelElement;
34
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\Xml\ModuleGenerator;
35
use PhpSpec\Process\Context\JsonExecutionContext;
36
use PhpSpec\ServiceContainer;
37
38
class GeneratorAssembler implements Assembler
39
{
40
    /**
41
     * @param ServiceContainer $container
42
     */
43
    public function build(ServiceContainer $container)
44
    {
45
        $this->setCodeGenerators($container);
46
        $this->setXmlModuleGenerator($container);
47
        $this->setXmlConfigGenerator($container);
48
        $this->setXmlElementGenerators($container);
49
    }
50
51
    /**
52
     * @param ServiceContainer $container
53
     */
54
    private function setCodeGenerators(ServiceContainer $container)
55
    {
56
        $container->setShared('code_generator.generators.mage_model', function ($c) {
57
            return new ModelGenerator(
58
                $c->get('console.io'),
59
                $c->get('code_generator.templates'),
60
                $c->get('filesystem'),
61
                new JsonExecutionContext()
62
            );
63
        });
64
65
        $container->setShared('code_generator.generators.mage_block', function ($c) {
66
            return new BlockGenerator(
67
                $c->get('console.io'),
68
                $c->get('code_generator.templates'),
69
                $c->get('filesystem'),
70
                new JsonExecutionContext()
71
            );
72
        });
73
74
        $container->setShared('code_generator.generators.mage_helper', function ($c) {
75
            return new HelperGenerator(
76
                $c->get('console.io'),
77
                $c->get('code_generator.templates'),
78
                $c->get('filesystem'),
79
                new JsonExecutionContext()
80
            );
81
        });
82
83
        $container->setShared('code_generator.generators.mage_controller', function($c) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
84
            return new ControllerGenerator(
85
                $c->get('console.io'),
86
                $c->get('code_generator.templates'),
87
                $c->get('filesystem'),
88
                new JsonExecutionContext()
89
            );
90
        });
91
92
        $container->setShared('code_generator.generators.controller_specification', function($c) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
93
            return new ControllerSpecificationGenerator(
94
                $c->get('console.io'),
95
                $c->get('code_generator.templates'),
96
                $c->get('filesystem'),
97
                new JsonExecutionContext()
98
            );
99
        });
100
    }
101
102
    /**
103
     * @param ServiceContainer $container
104
     */
105
    private function setXmlModuleGenerator(ServiceContainer $container)
106
    {
107
        $container->setShared('xml_generator.generators.module', function ($c) {
108
            $suite = $c->getParam('mage_locator', array('main' => ''));
109
            if (isset($suite['src_path'])) {
110
                $etcPath = rtrim($suite['src_path'], '/') . DIRECTORY_SEPARATOR . '..'
111
                    . DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR;
112
            } else {
113
                $etcPath = 'app/etc/';
114
            }
115
            $codePool = isset($suite['code_pool']) ? $suite['code_pool'] : 'local';
116
            return new ModuleGenerator(
117
                $etcPath,
118
                $c->get('filesystem'),
119
                $codePool
120
            );
121
        });
122
    }
123
124
    /**
125
     * @param ServiceContainer $container
126
     */
127
    private function setXmlConfigGenerator(ServiceContainer $container)
128
    {
129
        $container->setShared('xml_generator.generators.config', function($c) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
130
            $suite = $c->getParam('mage_locator', array('main' => ''));
131
            $srcPath = isset($suite['src_path']) ? rtrim($suite['src_path'], '/') . DIRECTORY_SEPARATOR : 'src';
132
            $codePool = isset($suite['code_pool']) ? $suite['code_pool'] : 'local';
133
            $generator = new ConfigGenerator(
134
                $srcPath,
135
                $c->get('filesystem'),
136
                $c->get('xml.formatter'),
137
                $codePool
138
            );
139
140
            array_map(
141
                array($generator, 'addElementGenerator'),
142
                $c->getByPrefix('xml_generator.generators.config.element')
143
            );
144
145
            return $generator;
146
        });
147
    }
148
149
    /**
150
     * @param ServiceContainer $container
151
     */
152
    private function setXmlElementGenerators(ServiceContainer $container)
153
    {
154
        $container->setShared('xml_generator.generators.config.element.block', function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
155
            return new BlockElement();
156
        });
157
158
        $container->setShared('xml_generator.generators.config.element.helper', function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
159
            return new HelperElement();
160
        });
161
162
        $container->setShared('xml_generator.generators.config.element.controller', function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
163
            return new ControllerElement();
164
        });
165
166
        $container->setShared('xml_generator.generators.config.element.model', function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
167
            return new ModelElement();
168
        });
169
    }
170
}
171