Completed
Push — develop ( 2c1e6b...179509 )
by Peter
01:59
created

ManipulatorFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 15

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 15
dl 0
loc 38
rs 9.1666
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B createService() 0 31 1
1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
6
 * @copyright   Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoDraw\Factory;
12
13
use WebinoDraw\Cache\DrawCache;
14
use WebinoDraw\Dom\Locator;
15
use WebinoDraw\Instructions\InstructionsRenderer;
16
use WebinoDraw\Manipulator\Manipulator;
17
use WebinoDraw\Manipulator\Plugin;
18
use WebinoDraw\VarTranslator\VarTranslator;
19
use Zend\ServiceManager\FactoryInterface;
20
use Zend\ServiceManager\ServiceLocatorInterface;
21
use Zend\View\Helper\EscapeHtml;
22
23
/**
24
 * Class ManipulatorFactory
25
 */
26
class ManipulatorFactory implements FactoryInterface
27
{
28
    /**
29
     * @param ServiceLocatorInterface $services
30
     * @return Manipulator
31
     */
32
    public function createService(ServiceLocatorInterface $services)
33
    {
34
        /** @var VarTranslator $varTranslator */
35
        $varTranslator = $services->get(VarTranslator::class);
36
        /** @var InstructionsRenderer $instructionsRenderer */
37
        $instructionsRenderer = $services->get(InstructionsRenderer::class);
38
        /** @var \WebinoDraw\Draw\LoopHelperPluginManager $drawLoopHelpers */
39
        $drawLoopHelpers = $services->get('WebinoDrawLoopHelperManager');
40
        /** @var DrawCache $drawCache */
41
        $drawCache = $services->get(DrawCache::class);
42
        /** @var \Zend\View\Renderer\PhpRenderer $viewRenderer */
43
        $viewRenderer = $services->get('ViewRenderer');
44
        /** @var Locator $domLocator */
45
        $domLocator = $services->get(Locator::class);
46
47
        return (new Manipulator($varTranslator))
48
            ->setPlugin(new Plugin\Loop($instructionsRenderer, $drawLoopHelpers, $drawCache), 500)
49
            ->setPlugin(new Plugin\Render($viewRenderer), 110)
50
            ->setPlugin(new Plugin\Fragments($domLocator), 100)
51
            ->setPlugin(new Plugin\NodeTranslation, 90)
52
            ->setPlugin(new Plugin\VarTranslation($varTranslator), 80)
53
            ->setPlugin(new Plugin\Remove($domLocator), 70)
54
            ->setPlugin(new Plugin\Replace, 60)
55
            ->setPlugin(new Plugin\Attribs, 50)
56
            ->setPlugin(new Plugin\Value(new EscapeHtml), 40)
57
            ->setPlugin(new Plugin\Html, 30)
58
            ->setPlugin(new Plugin\Cdata($instructionsRenderer), 20)
59
            ->setPlugin(new Plugin\OnVar($varTranslator, $instructionsRenderer), 10)
60
            ->setPlugin(new Plugin\OnEmpty($instructionsRenderer), -100)
61
            ->setPlugin(new Plugin\SubInstructions($instructionsRenderer), -500);
62
    }
63
}
64