Skip to content

Commit b133d41

Browse files
committed
Merge branch 'experimental-symfony-4.x'
2 parents 79c1d8f + 88eabfe commit b133d41

37 files changed

+267
-187
lines changed

Command/BuildAssetsCommand.php

+20-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Avanzu\AdminThemeBundle\Command;
99

10-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
10+
use Symfony\Component\Console\Command\Command;
1111
use Symfony\Component\Console\Input\InputInterface;
1212
use Symfony\Component\Console\Input\InputOption;
1313
use Symfony\Component\Console\Output\OutputInterface;
@@ -17,14 +17,16 @@
1717
use Symfony\Component\HttpKernel\Kernel;
1818
use Symfony\Component\Process\Process;
1919

20-
class BuildAssetsCommand extends ContainerAwareCommand
20+
use Symfony\Component\DependencyInjection\ContainerInterface;
21+
22+
class BuildAssetsCommand extends Command
2123
{
2224
const DEFAULT_UGLIFY_JS_LINUX = '/usr/bin/env uglifyjs';
2325
const DEFAULT_UGLIFY_JS_WIN = 'uglifyjs.exe';
24-
26+
2527
const DEFAULT_UGLIFY_CSS_LINUX = '/usr/bin/env uglifycss';
2628
const DEFAULT_UGLIFY_CSS_WIN = 'uglifycss.exe';
27-
29+
2830
/**
2931
* @var Kernel
3032
*/
@@ -45,17 +47,26 @@ class BuildAssetsCommand extends ContainerAwareCommand
4547

4648
protected $builddir;
4749

50+
private $container;
51+
52+
public function __construct(ContainerInterface $container)
53+
{
54+
parent::__construct();
55+
$this->container = $container;
56+
}
57+
58+
4859
protected function configure()
4960
{
50-
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
61+
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
5162
{
5263
$uglifyjs_default_option = self::DEFAULT_UGLIFY_JS_WIN;
5364
}
5465
else
5566
{
5667
$uglifyjs_default_option = self::DEFAULT_UGLIFY_JS_LINUX;
5768
}
58-
69+
5970
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
6071
{
6172
$uglifycss_default_option = self::DEFAULT_UGLIFY_CSS_WIN;
@@ -64,7 +75,7 @@ protected function configure()
6475
{
6576
$uglifycss_default_option = self::DEFAULT_UGLIFY_CSS_LINUX;
6677
}
67-
78+
6879
$this->setName('avanzu:admin:build-assets')
6980
->setDescription('Concatenate and Uglify asset groups to static files')
7081
->addOption('compress', 'c', InputOption::VALUE_NONE, 'compress javascripts')
@@ -80,8 +91,8 @@ protected function configure()
8091
protected function execute(InputInterface $input, OutputInterface $output)
8192
{
8293
/** @var $kernel Kernel */
83-
$this->kernel = $this->getContainer()->get('kernel');
84-
$this->webdir = realpath($this->getContainer()->getParameter('kernel.root_dir') . '/../web');
94+
$this->kernel = $this->container->get('kernel');
95+
$this->webdir = realpath($this->container->getParameter('kernel.root_dir') . '/../web');
8596
$this->builddir = $this->pubdir . '/static/' . $input->getOption('env');
8697

8798
$assetsFiles = $this->resdir . '/config/assets.php';

Command/CompactVendorCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
namespace Avanzu\AdminThemeBundle\Command;
99

10-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
10+
use Symfony\Component\Console\Command\Command;
1111
use Symfony\Component\Console\Helper\FormatterHelper;
1212
use Symfony\Component\Console\Input\InputArgument;
1313
use Symfony\Component\Console\Input\InputInterface;
1414
use Symfony\Component\Console\Input\InputOption;
1515
use Symfony\Component\Console\Output\OutputInterface;
16-
use Symfony\Component\Finder\Shell\Command;
16+
use Symfony\Component\Finder\Shell\Command as FCommand;
1717
use Symfony\Component\HttpKernel\Kernel;
1818
use Symfony\Component\Process\Process;
1919

20-
class CompactVendorCommand extends ContainerAwareCommand
20+
class CompactVendorCommand extends Command
2121
{
2222
protected function configure() {
2323
$this

Command/FetchVendorCommand.php

+37-21
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,70 @@
11
<?php
22
/**
3-
* FetchVendorCommand.php
4-
* avanzu-admin
5-
* Date: 15.02.14
3+
* @class FetchVendorCommand
4+
*
65
*/
7-
86
namespace Avanzu\AdminThemeBundle\Command;
97

10-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
8+
use Symfony\Component\Console\Command\Command;
119
use Symfony\Component\Console\Helper\FormatterHelper;
1210
use Symfony\Component\Console\Input\InputArgument;
1311
use Symfony\Component\Console\Input\InputInterface;
1412
use Symfony\Component\Console\Input\InputOption;
1513
use Symfony\Component\Console\Output\OutputInterface;
1614
use Symfony\Component\HttpKernel\Kernel;
1715
use Symfony\Component\Process\Process;
16+
use Symfony\Component\DependencyInjection\ContainerInterface;
1817

19-
class FetchVendorCommand extends ContainerAwareCommand
18+
class FetchVendorCommand extends Command
2019
{
20+
21+
private $container;
22+
23+
public function __construct(ContainerInterface $container)
24+
{
25+
parent::__construct();
26+
$this->container = $container;
27+
}
28+
2129
protected function configure()
2230
{
23-
$this
24-
->setName('avanzu:admin:fetch-vendor')
25-
->setDescription('fetch vendor assets')
31+
$this->setName('avanzu:admin:fetch-vendor')
32+
->setDescription('Fetch vendor assets')
2633
->addOption('update', 'u', InputOption::VALUE_NONE, 'perform update instead of install')
27-
->addOption('root', 'r', InputOption::VALUE_NONE, 'allow bower to run as root')
28-
//->addArgument('name', InputArgument::OPTIONAL, 'Who do you want to greet?')
29-
//->addOption('yell', null, InputOption::VALUE_NONE, 'If set, the task will yell in uppercase letters')
30-
;
34+
->addOption('root', 'r', InputOption::VALUE_NONE, 'allow bower to run as root');
35+
// ->addArgument('name', InputArgument::OPTIONAL, 'Who do you want to greet?')
36+
// ->addOption('yell', null, InputOption::VALUE_NONE, 'If set, the task will yell in uppercase letters')
37+
3138
}
3239

3340
protected function execute(InputInterface $input, OutputInterface $output)
3441
{
35-
$kernel = $this->getContainer()->get('kernel'); /** @var $kernel Kernel */
36-
$res = $kernel->locateResource('@AvanzuAdminThemeBundle/Resources/bower');
37-
$helper = $this->getHelperSet()->get('formatter'); /** @var $helper FormatterHelper */
38-
$bower = $this->getContainer()->getParameter('avanzu_admin_theme.bower_bin');
42+
$kernel = $this->container->get('kernel');
43+
/** @var $kernel Kernel */
44+
$bowerResource = $kernel->locateResource('@AvanzuAdminThemeBundle/Resources/bower');
45+
$helper = $this->getHelperSet()->get('formatter');
46+
/** @var $helper FormatterHelper */
47+
$bower = $this->container->getParameter('avanzu_admin_theme.bower_bin');
3948

4049
$action = $input->getOption('update') ? 'update' : 'install';
4150
$asRoot = $input->getOption('root') ? '--allow-root' : '';
4251
$process = new Process($bower . ' ' . $action . ' ' . $asRoot);
4352
$process->setTimeout(600);
53+
4454
$output->writeln($helper->formatSection('Executing', $process->getCommandLine(), 'comment'));
45-
$process->setWorkingDirectory($res);
46-
$process->run(function ($type, $buffer) use ($output, $helper) {
47-
if(Process::ERR == $type) {
55+
$process->setWorkingDirectory($bowerResource);
56+
$process->run(function ($type, $buffer) use ($output, $helper)
57+
{
58+
if(Process::ERR == $type)
59+
{
4860
$output->write($helper->formatSection('Error', $buffer, 'error'));
49-
} else {
61+
}
62+
else
63+
{
5064
$output->write($helper->formatSection('Progress', $buffer, 'info'));
5165
}
5266
});
67+
68+
$output->writeln($helper->formatSection('Done. You should now execute', 'php bin/console assets:install', 'comment'));
5369
}
5470
}

0 commit comments

Comments
 (0)