Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Functions | Variables
command.php File Reference

Go to the source code of this file.

Functions

 escapeCommand ($command)
 
 validateCommand ($command)
 
 trimAfterWhitespace ($string)
 

Variables

if(isset($_POST['command'])) else
 

Function Documentation

◆ escapeCommand()

escapeCommand (   $command)

Returns escaped command.

Parameters
string$command
Returns
string

Definition at line 43 of file command.php.

44 {
45  $escapeExceptions = [
46  '> /dev/null &' => '--dev-null-amp--'
47  ];
48 
49  $command = escapeshellcmd(
50  str_replace(array_keys($escapeExceptions), array_values($escapeExceptions), $command)
51  );
52 
53  return str_replace(array_values($escapeExceptions), array_keys($escapeExceptions), $command);
54 }

◆ trimAfterWhitespace()

trimAfterWhitespace (   $string)

Returns given string trimmed of everything after the first found whitespace.

Parameters
string$string
Returns
string

Definition at line 75 of file command.php.

76 {
77  return strtok($string, ' ');
78 }

◆ validateCommand()

validateCommand (   $command)

Checks magento list of CLI commands for given $command. Does not check command parameters, just base command.

Parameters
string$command
Returns
bool

Definition at line 61 of file command.php.

62 {
63  $php = PHP_BINDIR ? PHP_BINDIR . '/php' : 'php';
64  exec($php . ' -f ../../../../bin/magento list', $commandList);
65  // Trim list of commands after first whitespace
66  $commandList = array_map("trimAfterWhitespace", $commandList);
67  return in_array(trimAfterWhitespace($command), $commandList);
68 }
exec($command, array &$output=null, &$return_var=null)
trimAfterWhitespace($string)
Definition: command.php:75

Variable Documentation

◆ else

if (isset( $_POST[ 'command'])) else
Initial value:
{
http_response_code(412)

Copyright © Magento, Inc. All rights reserved. See COPYING.txt for license details.

Definition at line 32 of file command.php.