FineInstaller   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A install() 0 18 3
1
<?php
2
namespace Mouf\Utils\I18n\Fine\Common;
3
4
use Mouf\Installer\PackageInstallerInterface;
5
use Mouf\MoufManager;
6
use Mouf\Actions\InstallUtils;
7
8
/**
9
 * Installer for common fine package. This create a defaultTranslationService
10
 */
11
class FineInstaller implements PackageInstallerInterface
12
{
13
14
    /**
15
     * (non-PHPdoc)
16
     * @see \Mouf\Installer\PackageInstallerInterface::install()
17
     */
18
    public static function install(MoufManager $moufManager)
19
    {
20
        $cascadingTranslator = InstallUtils::getOrCreateInstance("defaultTranslationService", "Mouf\\Utils\\I18n\\Fine\\Common\\FineCascadingTranslator", $moufManager);
21
22
        if ($moufManager->has('twigEnvironment') && !$moufManager->has('fineTwigExtension')) {
23
            $fineTwigExtension = $moufManager->createInstance(FineTwigExtension::class);
24
25
            $fineTwigExtension->getConstructorArgumentProperty('translator')->setValue($cascadingTranslator);
26
27
            $twigEnvironment = $moufManager->getInstanceDescriptor('twigEnvironment');
28
            $extensions = $twigEnvironment->getSetterProperty('setExtensions')->getValue();
29
            $extensions[] = $fineTwigExtension;
30
            $twigEnvironment->getSetterProperty('setExtensions')->setValue($extensions);
31
        }
32
33
        // Let's rewrite the MoufComponents.php file to save the component
34
        $moufManager->rewriteMouf();
35
    }
36
}
37