Skip to content

Commit

Permalink
[console] Add missing docblocks and apply PSR-2 code style. (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas committed Dec 30, 2016
1 parent 604ecca commit 221ad3b
Show file tree
Hide file tree
Showing 38 changed files with 297 additions and 46 deletions.
19 changes: 19 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\Console\Core;

use Drupal\Console\Core\Utils\TranslatorManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -53,6 +54,9 @@ public function __construct(
$this->addOptions();
}

/**
* @return TranslatorManager
*/
public function getTranslator()
{
if ($this->container) {
Expand All @@ -76,6 +80,9 @@ public function trans($key)
return null;
}

/**
* {@inheritdoc}
*/
public function doRun(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
Expand Down Expand Up @@ -119,6 +126,9 @@ public function doRun(InputInterface $input, OutputInterface $output)
return $code;
}

/**
* registerEvents
*/
private function registerEvents()
{
$dispatcher = new EventDispatcher();
Expand Down Expand Up @@ -169,6 +179,9 @@ private function registerEvents()
$this->setDispatcher($dispatcher);
}

/**
* addOptions
*/
private function addOptions()
{
$this->getDefinition()->addOption(
Expand Down Expand Up @@ -253,6 +266,9 @@ private function addOptions()
);
}

/**
* registerCommandsFromAutoWireConfiguration
*/
private function registerCommandsFromAutoWireConfiguration()
{
$configuration = $this->container->get('console.configuration_manager')
Expand Down Expand Up @@ -339,6 +355,9 @@ private function registerCommandsFromAutoWireConfiguration()
}
}

/**
* registerChainCommands
*/
public function registerChainCommands()
{
/**
Expand Down
13 changes: 13 additions & 0 deletions src/Bootstrap/DrupalConsoleCore.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
<?php

/**
* @file
* Contains \Drupal\Console\Core\Bootstrap.
*/

namespace Drupal\Console\Core\Bootstrap;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

/**
* Class DrupalConsoleCore
* @package Drupal\Console\Core\Bootstrap
*/
class DrupalConsoleCore
{
/**
Expand All @@ -17,6 +26,7 @@ class DrupalConsoleCore
* @var string
*/
protected $appRoot;

/**
* DrupalConsole constructor.
* @param $root
Expand All @@ -28,6 +38,9 @@ public function __construct($root, $appRoot = null)
$this->appRoot = $appRoot;
}

/**
* @return ContainerBuilder
*/
public function boot()
{
$container = new ContainerBuilder();
Expand Down
8 changes: 4 additions & 4 deletions src/Command/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
$commands = [
'init' => [
$this->trans('commands.init.description'),
'drupal init --override --no-interaction'
'drupal init'
],
// 'quick-start' => [
// $this->trans('commands.common.messages.quick-start'),
// 'drupal chain --file=~/.console/chain/quick-start.yml'
// 'drupal quick:start'
// ],
// 'site-new' => [
// $this->trans('commands.site.new.description'),
// 'drupal site:new drupal8.dev --latest'
// 'drupal site:new'
// ],
'site-install' => [
$this->trans('commands.site.install.description'),
sprintf(
'drupal site:install'
)
],
'links' => [
'list' => [
$this->trans('commands.list.description'),
'drupal list',
]
Expand Down
5 changes: 2 additions & 3 deletions src/Command/Chain/ChainCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ class ChainCommand extends Command

/**
* ChainCommand constructor.
* @param ChainQueue $chainQueue
* @param ChainDiscovery $chainDiscovery
* @param ChainQueue $chainQueue
* @param ChainDiscovery $chainDiscovery
*/
public function __construct(
ChainQueue $chainQueue,
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Chain/ChainCustomCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$arguments['--placeholder'] = $this->inlineValueAsArray($placeholder);
}

foreach($input->getOptions() as $option => $value) {
foreach ($input->getOptions() as $option => $value) {
if ($option != 'placeholder' && $value) {
if (is_bool($value)) {
$value = true;
Expand Down
1 change: 1 addition & 0 deletions src/Command/Chain/ChainDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function __construct(

parent::__construct();
}

/**
* {@inheritdoc}
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Command/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$checks['php']['required']
)
);

return 1;
}

if ($extensions = $checks['extensions']['required']['missing']) {
Expand Down
2 changes: 2 additions & 0 deletions src/Command/CompleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$commands = array_keys($this->getApplication()->all());
asort($commands);
$output->writeln($commands);

return 0;
}
}
15 changes: 14 additions & 1 deletion src/Command/Exclude/DrupliconCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@
use Drupal\Console\Core\Utils\TwigRenderer;
use Drupal\Console\Core\Style\DrupalStyle;

/**
* Class DrupliconCommand
* @package Drupal\Console\Core\Command\Exclude
*/
class DrupliconCommand extends Command
{
use CommandTrait;

/**
* @var string
*/
protected $appRoot;
/**
* @var TwigRenderer
Expand All @@ -39,13 +46,19 @@ public function __construct(
parent::__construct();
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('druplicon')
->setDescription($this->trans('application.commands.druplicon.description'));
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
Expand All @@ -61,7 +74,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
->in($directory);

$templates = [];

foreach ($finder as $template) {
$templates[] = $template->getRelativePathname();
}
Expand All @@ -74,5 +86,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
);

$io->writeln($druplicon);
return 0;
}
}
10 changes: 10 additions & 0 deletions src/Command/Exclude/DrushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
use Drupal\Console\Core\Utils\ChainQueue;
use Drupal\Console\Core\Style\DrupalStyle;

/**
* Class DrushCommand
* @package Drupal\Console\Core\Command\Exclude
*/
class DrushCommand extends Command
{
use CommandTrait;
Expand Down Expand Up @@ -44,6 +48,9 @@ public function __construct(
parent::__construct();
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
Expand All @@ -57,6 +64,9 @@ protected function configure()
);
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
Expand Down
15 changes: 15 additions & 0 deletions src/Command/Exclude/ElephpantCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@
use Drupal\Console\Core\Utils\TwigRenderer;
use Drupal\Console\Core\Style\DrupalStyle;

/**
* Class ElephpantCommand
* @package Drupal\Console\Core\Command\Exclude
*/
class ElephpantCommand extends Command
{
use CommandTrait;

/**
* @var string
*/
protected $appRoot;

/**
* @var TwigRenderer
*/
Expand All @@ -39,13 +47,19 @@ public function __construct(
parent::__construct();
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('elephpant')
->setDescription($this->trans('application.commands.elephpant.description'));
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
Expand Down Expand Up @@ -74,5 +88,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
);

$io->writeln($elephpant);
return 0;
}
}
3 changes: 1 addition & 2 deletions src/Command/Exec/ExecCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ protected function configure()
null,
InputOption::VALUE_OPTIONAL,
$this->trans('commands.exec.options.working-directory')
)
;
);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$this->trans('commands.init.questions.destination'),
$this->configurationManager->getConfigurationDirectories()
);
}
else {
} else {
$destination = $this->configurationManager
->getConsoleDirectory();
}
Expand Down Expand Up @@ -238,6 +237,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
);

$io->writeln($this->trans('application.messages.autocomplete'));

return 0;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
use Drupal\Console\Core\Command\Shared\CommandTrait;
use Drupal\Console\Core\Style\DrupalStyle;

/**
* Class ListCommand
* @package Drupal\Console\Core\Command
*/
class ListCommand extends Command
{
use CommandTrait;
Expand Down
1 change: 0 additions & 1 deletion src/Command/Settings/SetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class SetCommand extends Command
*/
protected $nestedArray;


/**
* CheckCommand constructor.
* @param ConfigurationManager $configurationManager
Expand Down
11 changes: 8 additions & 3 deletions src/Command/ShellCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
use Symfony\Component\Console\Command\Command;
use Drupal\Console\Core\Command\Shared\CommandTrait;

class ShellCommand extends Command {

/**
* Class ShellCommand
* @package Drupal\Console\Core\Command
*/
class ShellCommand extends Command
{
use CommandTrait;

/**
Expand All @@ -27,7 +31,8 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) {
protected function execute(InputInterface $input, OutputInterface $output)
{
$config = new Configuration;
$shell = new Shell($config);
$shell->run();
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Site/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private function siteDetail($target)
}

/**
* @param string $sitesDirectory
* @param string $sitesDirectory
* @return array
*/
private function siteList($sitesDirectory)
Expand Down
Loading

0 comments on commit 221ad3b

Please sign in to comment.