forked from hechoendrupal/drupal-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrushCommand.php
More file actions
44 lines (39 loc) · 1.19 KB
/
Copy pathDrushCommand.php
File metadata and controls
44 lines (39 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* @file
* Contains \Drupal\AppConsole\Command\DrushCommand.
*/
namespace Drupal\AppConsole\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class DrushCommand extends ContainerAwareCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('drush')
->setDescription($this->trans('commands.drush.description'))
->addArgument('args', InputArgument::IS_ARRAY, $this->trans('commands.drush.arguments.args'))
->setHelp($this->trans('commands.drush.help'));
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$args = '';
if ($arguments = $input->getArgument('args')) {
$args .= ' ' . implode(' ', $arguments);
$c_args = preg_replace('/[^a-z0-9-= ]/i', '', $args);
}
if (`which drush`) {
system('drush' . $c_args);
} else {
$output->write("<error>" . $this->trans('commands.drush.message.not_found') . "</error>");
}
}
}