ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Symfony\Component\Process\ProcessBuilder Class Reference

Process builder. More...

+ Collaboration diagram for Symfony\Component\Process\ProcessBuilder:

Public Member Functions

 __construct (array $arguments=array())
 Constructor. More...
 
 add ($argument)
 Adds an unescaped argument to the command string. More...
 
 setPrefix ($prefix)
 Adds a prefix to the command string. More...
 
 setArguments (array $arguments)
 Sets the arguments of the process. More...
 
 setWorkingDirectory ($cwd)
 Sets the working directory. More...
 
 inheritEnvironmentVariables ($inheritEnv=true)
 Sets whether environment variables will be inherited or not. More...
 
 setEnv ($name, $value)
 Sets an environment variable. More...
 
 addEnvironmentVariables (array $variables)
 Adds a set of environment variables. More...
 
 setInput ($input)
 Sets the input of the process. More...
 
 setTimeout ($timeout)
 Sets the process timeout. More...
 
 setOption ($name, $value)
 Adds a proc_open option. More...
 
 disableOutput ()
 Disables fetching output and error output from the underlying process. More...
 
 enableOutput ()
 Enables fetching output and error output from the underlying process. More...
 
 getProcess ()
 Creates a Process instance and returns it. More...
 

Static Public Member Functions

static create (array $arguments=array())
 Creates a process builder instance. More...
 

Private Attributes

 $arguments
 
 $cwd
 
 $env = array()
 
 $input
 
 $timeout = 60
 
 $options = array()
 
 $inheritEnv = true
 
 $prefix = array()
 
 $outputDisabled = false
 

Detailed Description

Process builder.

Author
Kris Wallsmith kris@.nosp@m.symf.nosp@m.ony.c.nosp@m.om

Definition at line 22 of file ProcessBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

Symfony\Component\Process\ProcessBuilder::__construct ( array  $arguments = array())

Constructor.

Parameters
string[]$arguments An array of arguments

Definition at line 39 of file ProcessBuilder.php.

References Symfony\Component\Process\ProcessBuilder\$arguments.

40  {
41  $this->arguments = $arguments;
42  }

Member Function Documentation

◆ add()

Symfony\Component\Process\ProcessBuilder::add (   $argument)

Adds an unescaped argument to the command string.

Parameters
string$argumentA command argument
Returns
ProcessBuilder

Definition at line 63 of file ProcessBuilder.php.

64  {
65  $this->arguments[] = $argument;
66 
67  return $this;
68  }

◆ addEnvironmentVariables()

Symfony\Component\Process\ProcessBuilder::addEnvironmentVariables ( array  $variables)

Adds a set of environment variables.

Already existing environment variables with the same name will be overridden by the new values passed to this method. Pass null to unset a variable.

Parameters
array$variablesThe variables
Returns
ProcessBuilder

Definition at line 160 of file ProcessBuilder.php.

161  {
162  $this->env = array_replace($this->env, $variables);
163 
164  return $this;
165  }

◆ create()

◆ disableOutput()

Symfony\Component\Process\ProcessBuilder::disableOutput ( )

Disables fetching output and error output from the underlying process.

Returns
ProcessBuilder

Definition at line 233 of file ProcessBuilder.php.

234  {
235  $this->outputDisabled = true;
236 
237  return $this;
238  }

◆ enableOutput()

Symfony\Component\Process\ProcessBuilder::enableOutput ( )

Enables fetching output and error output from the underlying process.

Returns
ProcessBuilder

Definition at line 245 of file ProcessBuilder.php.

246  {
247  $this->outputDisabled = false;
248 
249  return $this;
250  }

◆ getProcess()

Symfony\Component\Process\ProcessBuilder::getProcess ( )

Creates a Process instance and returns it.

Returns
Process
Exceptions
LogicExceptionIn case no arguments have been provided

Definition at line 259 of file ProcessBuilder.php.

References $_SERVER, Symfony\Component\Process\ProcessBuilder\$arguments, Symfony\Component\Process\ProcessBuilder\$env, Symfony\Component\Process\ProcessBuilder\$options, array, and input.

260  {
261  if (0 === count($this->prefix) && 0 === count($this->arguments)) {
262  throw new LogicException('You must add() command arguments before calling getProcess().');
263  }
264 
266 
267  $arguments = array_merge($this->prefix, $this->arguments);
268  $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
269 
270  if ($this->inheritEnv) {
271  $env = array_replace($_ENV, $_SERVER, $this->env);
272  } else {
273  $env = $this->env;
274  }
275 
276  $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options);
277 
278  if ($this->outputDisabled) {
279  $process->disableOutput();
280  }
281 
282  return $process;
283  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
input
Definition: langcheck.php:166
Create styles array
The data for the language used.

◆ inheritEnvironmentVariables()

Symfony\Component\Process\ProcessBuilder::inheritEnvironmentVariables (   $inheritEnv = true)

Sets whether environment variables will be inherited or not.

Parameters
bool$inheritEnv
Returns
ProcessBuilder

Definition at line 124 of file ProcessBuilder.php.

References Symfony\Component\Process\ProcessBuilder\$inheritEnv.

125  {
126  $this->inheritEnv = $inheritEnv;
127 
128  return $this;
129  }

◆ setArguments()

Symfony\Component\Process\ProcessBuilder::setArguments ( array  $arguments)

Sets the arguments of the process.

Arguments must not be escaped. Previous arguments are removed.

Parameters
string[]$arguments
Returns
ProcessBuilder

Definition at line 96 of file ProcessBuilder.php.

References Symfony\Component\Process\ProcessBuilder\$arguments.

97  {
98  $this->arguments = $arguments;
99 
100  return $this;
101  }

◆ setEnv()

Symfony\Component\Process\ProcessBuilder::setEnv (   $name,
  $value 
)

Sets an environment variable.

Setting a variable overrides its previous value. Use null to unset a defined environment variable.

Parameters
string$nameThe variable name
null | string$valueThe variable value
Returns
ProcessBuilder

Definition at line 142 of file ProcessBuilder.php.

Referenced by Assetic\Filter\BaseProcessFilter\mergeEnv().

143  {
144  $this->env[$name] = $value;
145 
146  return $this;
147  }
+ Here is the caller graph for this function:

◆ setInput()

Symfony\Component\Process\ProcessBuilder::setInput (   $input)

Sets the input of the process.

Parameters
resource | scalar | \Traversable | null$inputThe input content
Returns
ProcessBuilder
Exceptions
InvalidArgumentExceptionIn case the argument is invalid

Definition at line 176 of file ProcessBuilder.php.

References Symfony\Component\Process\ProcessBuilder\$input, input, and Symfony\Component\Process\ProcessUtils\validateInput().

177  {
178  $this->input = ProcessUtils::validateInput(__METHOD__, $input);
179 
180  return $this;
181  }
input
Definition: langcheck.php:166
static validateInput($caller, $input)
Validates and normalizes a Process input.
+ Here is the call graph for this function:

◆ setOption()

Symfony\Component\Process\ProcessBuilder::setOption (   $name,
  $value 
)

Adds a proc_open option.

Parameters
string$nameThe option name
string$valueThe option value
Returns
ProcessBuilder

Definition at line 221 of file ProcessBuilder.php.

222  {
223  $this->options[$name] = $value;
224 
225  return $this;
226  }

◆ setPrefix()

Symfony\Component\Process\ProcessBuilder::setPrefix (   $prefix)

Adds a prefix to the command string.

The prefix is preserved when resetting arguments.

Parameters
string | array$prefixA command prefix or an array of command prefixes
Returns
ProcessBuilder

Definition at line 79 of file ProcessBuilder.php.

References Symfony\Component\Process\ProcessBuilder\$prefix, and array.

80  {
81  $this->prefix = is_array($prefix) ? $prefix : array($prefix);
82 
83  return $this;
84  }
Create styles array
The data for the language used.

◆ setTimeout()

Symfony\Component\Process\ProcessBuilder::setTimeout (   $timeout)

Sets the process timeout.

To disable the timeout, set this value to null.

Parameters
float | null$timeout
Returns
ProcessBuilder
Exceptions
InvalidArgumentException

Definition at line 194 of file ProcessBuilder.php.

References Symfony\Component\Process\ProcessBuilder\$timeout.

195  {
196  if (null === $timeout) {
197  $this->timeout = null;
198 
199  return $this;
200  }
201 
202  $timeout = (float) $timeout;
203 
204  if ($timeout < 0) {
205  throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
206  }
207 
208  $this->timeout = $timeout;
209 
210  return $this;
211  }

◆ setWorkingDirectory()

Symfony\Component\Process\ProcessBuilder::setWorkingDirectory (   $cwd)

Sets the working directory.

Parameters
null | string$cwdThe working directory
Returns
ProcessBuilder

Definition at line 110 of file ProcessBuilder.php.

References Symfony\Component\Process\ProcessBuilder\$cwd.

111  {
112  $this->cwd = $cwd;
113 
114  return $this;
115  }

Field Documentation

◆ $arguments

◆ $cwd

Symfony\Component\Process\ProcessBuilder::$cwd
private

◆ $env

Symfony\Component\Process\ProcessBuilder::$env = array()
private

◆ $inheritEnv

Symfony\Component\Process\ProcessBuilder::$inheritEnv = true
private

◆ $input

Symfony\Component\Process\ProcessBuilder::$input
private

◆ $options

Symfony\Component\Process\ProcessBuilder::$options = array()
private

◆ $outputDisabled

Symfony\Component\Process\ProcessBuilder::$outputDisabled = false
private

Definition at line 32 of file ProcessBuilder.php.

◆ $prefix

Symfony\Component\Process\ProcessBuilder::$prefix = array()
private

◆ $timeout

Symfony\Component\Process\ProcessBuilder::$timeout = 60
private

The documentation for this class was generated from the following file: