Completed
Push — master ( 68693d...b79797 )
by Adam
12:25
created

PackageController::getProcessHelper()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 *
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 *
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\AppBundle\Controller\Admin;
14
15
use SensioLabs\AnsiConverter\AnsiToHtmlConverter;
16
use SensioLabs\AnsiConverter\Theme\SolarizedTheme;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\HttpFoundation\StreamedResponse;
19
use WellCommerce\Bundle\AppBundle\Entity\Package;
20
use WellCommerce\Bundle\AppBundle\Manager\PackageManager;
21
use WellCommerce\Bundle\CoreBundle\Console\Output\ConsoleHtmlOutput;
22
use WellCommerce\Bundle\CoreBundle\Controller\Admin\AbstractAdminController;
23
use WellCommerce\Bundle\CoreBundle\Helper\Package\PackageHelperInterface;
24
use WellCommerce\Bundle\CoreBundle\Helper\Process\ProcessHelperInterface;
25
26
/**
27
 * Class PackageController
28
 *
29
 * @author  Adam Piotrowski <[email protected]>
30
 */
31
class PackageController extends AbstractAdminController
32
{
33
    /**
34
     * @var PackageManager
35
     */
36
    protected $manager;
37
    
38
    public function indexAction(): Response
39
    {
40
        $this->manager->syncPackages(PackageHelperInterface::DEFAULT_PACKAGE_BUNDLE_TYPE);
41
        $this->manager->syncPackages(PackageHelperInterface::DEFAULT_PACKAGE_THEME_TYPE);
42
        $this->manager->getFlashHelper()->addSuccess('package.flash.sync.success');
0 ignored issues
show
Bug introduced by
The method getFlashHelper() cannot be called from this context as it is declared protected in class WellCommerce\Bundle\Core...\AbstractContainerAware.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
43
        
44
        return $this->displayTemplate('index', [
45
            'datagrid' => $this->dataGrid,
46
        ]);
47
    }
48
    
49
    public function packageAction(Package $package, $operation)
50
    {
51
        $form = $this->formBuilder->createForm($package);
52
        
53
        return $this->displayTemplate('package', [
54
            'operation'   => $operation,
55
            'packageName' => $package->getFullName(),
56
            'form'        => $form,
57
        ]);
58
    }
59
    
60
    public function runAction(Package $package, string $operation)
61
    {
62
        $output    = new ConsoleHtmlOutput();
63
        $arguments = ['app/console', 'wellcommerce:package:' . $operation, '--package=' . $package->getName(),];
64
        $process   = $this->getProcessHelper()->createProcess($arguments);
65
        $process->start();
66
        
67
        foreach ($process as $type => $data) {
68
            $output->write($data);
69
        }
70
        
71
        return new Response('');
72
    }
73
    
74
    private function getProcessHelper(): ProcessHelperInterface
75
    {
76
        return $this->get('process.helper');
77
    }
78
}
79