Skip to content

Commit b9d7cf1

Browse files
author
Olga Kopylova
committed
Merge pull request magento#1031 from magento-ogre/develop
[Ogre] Bug fix, MAGETWO-31889
2 parents 76d6838 + c3714c2 commit b9d7cf1

File tree

5 files changed

+54
-40
lines changed

5 files changed

+54
-40
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"zendframework/zend-serializer": "2.3.1",
3030
"zendframework/zend-log": "2.3.1",
3131
"zendframework/zend-http": "2.3.1",
32-
"magento/zendframework1": "1.12.9",
32+
"magento/zendframework1": "1.12.9-patch1",
3333
"composer/composer": "1.0.0-alpha8"
3434
},
3535
"require-dev": {

composer.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup/module/Magento/Setup/Module.php

+1-25
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,17 @@
55

66
namespace Magento\Setup;
77

8-
use Magento\Setup\Controller\ConsoleController;
98
use Magento\Setup\Mvc\Bootstrap\InitParamListener;
109
use Magento\Setup\Mvc\View\Http\InjectTemplateListener;
11-
use Zend\Console\Adapter\AdapterInterface;
1210
use Zend\EventManager\EventInterface;
1311
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
1412
use Zend\ModuleManager\Feature\ConfigProviderInterface;
15-
use Zend\ModuleManager\Feature\ConsoleBannerProviderInterface;
16-
use Zend\ModuleManager\Feature\ConsoleUsageProviderInterface;
1713
use Zend\Mvc\ModuleRouteListener;
1814
use Zend\Mvc\MvcEvent;
1915

2016
class Module implements
2117
BootstrapListenerInterface,
22-
ConfigProviderInterface,
23-
ConsoleBannerProviderInterface,
24-
ConsoleUsageProviderInterface
18+
ConfigProviderInterface
2519
{
2620
/**
2721
* {@inheritdoc}
@@ -74,22 +68,4 @@ public function getConfig()
7468
$result = InitParamListener::attachToConsoleRoutes($result);
7569
return $result;
7670
}
77-
78-
/**
79-
* {@inheritdoc}
80-
*/
81-
public function getConsoleBanner(AdapterInterface $console)
82-
{
83-
return "==-------------------==\n"
84-
. " Magento Setup CLI \n"
85-
. "==-------------------==\n";
86-
}
87-
88-
/**
89-
* {@inheritdoc}
90-
*/
91-
public function getConsoleUsage(AdapterInterface $console)
92-
{
93-
return array_merge(ConsoleController::getConsoleUsage(), InitParamListener::getConsoleUsage());
94-
}
9571
}

setup/module/Magento/Setup/src/Controller/ConsoleController.php

+38-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
use Magento\Setup\Model\InstallerFactory;
1414
use Magento\Setup\Model\Lists;
1515
use Magento\Setup\Model\UserConfigurationDataMapper as UserConfig;
16+
use Magento\Setup\Mvc\Bootstrap\InitParamListener;
1617
use Zend\Console\Request as ConsoleRequest;
1718
use Zend\EventManager\EventManagerInterface;
1819
use Zend\Mvc\Controller\AbstractActionController;
1920

21+
2022
/**
2123
* Controller that handles all setup commands via command line interface.
2224
*
@@ -242,7 +244,7 @@ private static function getCliConfig()
242244
'usage_desc' => 'Set maintenance mode, optionally for specified addresses',
243245
],
244246
self::CMD_HELP => [
245-
'route' => self::CMD_HELP . ' (' . implode('|', self::$helpOptions) . '):type',
247+
'route' => self::CMD_HELP . ' [' . implode('|', self::$helpOptions) . ']:type',
246248
'usage' => '<' . implode('|', self::$helpOptions) . '>',
247249
'usage_short' => self::CMD_HELP . ' <topic>',
248250
'usage_desc' => 'Help about particular command or topic:',
@@ -433,6 +435,12 @@ public function maintenanceAction()
433435
public function helpAction()
434436
{
435437
$type = $this->getRequest()->getParam('type');
438+
if ($type === false) {
439+
$usageInfo = $this->formatConsoleFullUsageInfo(
440+
array_merge(self::getConsoleUsage(), InitParamListener::getConsoleUsage())
441+
);
442+
return $usageInfo;
443+
}
436444
$usages = self::getCommandUsage();
437445
switch($type) {
438446
case UserConfig::KEY_LANGUAGE:
@@ -453,6 +461,35 @@ public function helpAction()
453461
}
454462
}
455463

464+
/**
465+
* Formats full usage info for console when user inputs 'help' command with no type
466+
*
467+
* @param array $usageInfo
468+
* @return string
469+
*/
470+
private function formatConsoleFullUsageInfo($usageInfo)
471+
{
472+
$result = "\n==-------------------==\n"
473+
. " Magento Setup CLI \n"
474+
. "==-------------------==\n";
475+
$mask = "%-50s %-30s\n";
476+
$script = 'index.php';
477+
foreach ($usageInfo as $key => $value) {
478+
if ($key === 0) {
479+
$result .= sprintf($mask, "\n$value", '');
480+
} elseif (is_numeric($key)) {
481+
if (is_array($value)) {
482+
$result .= sprintf($mask, " " . $value[0], $value[1]);
483+
} else {
484+
$result .= sprintf($mask, '', $value);
485+
}
486+
} else {
487+
$result .= sprintf($mask, " $script " . $key, $value);
488+
}
489+
}
490+
return $result;
491+
}
492+
456493
/**
457494
* Formats output of "usage" into more readable format by grouping required/optional parameters and wordwrapping
458495
*

setup/module/Magento/Setup/src/Mvc/Console/VerboseValidator.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@ class VerboseValidator
2222
public function validate(array $data, array $config)
2323
{
2424
$validationMessages = '';
25+
$userAction = null;
2526
if (!empty($data)) {
2627
$userAction = $data[0];
2728
array_shift($data);
28-
} else {
29-
// user did not provide any action or parameters, treat as default action
30-
return '';
3129
}
32-
33-
if (isset($config[$userAction])) {
30+
if (isset($userAction) && isset($config[$userAction])) {
3431
// parse the expected parameters of the action
3532
$matcher = new RouteMatcher($config[$userAction]['options']['route']);
3633
$parts = $matcher->getParts();
@@ -87,8 +84,12 @@ public function validate(array $data, array $config)
8784
$validationMessages .= 'Usage:' . PHP_EOL . "{$userAction} ";
8885
$validationMessages .= $usages[$userAction] . PHP_EOL . PHP_EOL;
8986

90-
} else if (!is_null($userAction)) {
91-
$validationMessages .= PHP_EOL . "Unknown action name '{$userAction}'." . PHP_EOL . PHP_EOL;
87+
} else {
88+
if (!is_null($userAction)) {
89+
$validationMessages .= PHP_EOL . "Unknown action name '{$userAction}'." . PHP_EOL . PHP_EOL;
90+
} else {
91+
$validationMessages .= PHP_EOL . "No action is given in the command." . PHP_EOL . PHP_EOL;
92+
}
9293
$validationMessages .= 'Available options: ' . PHP_EOL;
9394
foreach (array_keys($config) as $action) {
9495
$validationMessages .= $action . PHP_EOL;

0 commit comments

Comments
 (0)