class FilesystemStack extends StackBasedTask implements BuilderAwareInterface (View source)

Wrapper for Symfony Filesystem Component.

Comands are executed in stack and can be stopped on first fail with stopOnFail option.

<?php
$this->taskFilesystemStack()
     ->mkdir('logs')
     ->touch('logs/.gitignore')
     ->chgrp('www', 'www-data')
     ->symlink('/var/log/nginx/error.log', 'logs/error.log')
     ->run();

// one line
$this->_touch('.gitignore');
$this->_mkdir('logs');

?>

Traits

Task input/output methods. TaskIO is 'used' in BaseTask, so any task that extends this class has access to all of the methods here.

Task input/output methods. TaskIO is 'used' in BaseTask, so any task that extends this class has access to all of the methods here.

LoggerAwareTrait

Properties

protected ConfigInterface $config from  ConfigAwareTrait
protected OutputAdapterInterface $outputAdapter from  VerbosityThresholdTrait
protected int $verbosityThreshold from  VerbosityThresholdTrait
protected OutputInterface $output from  OutputAwareTrait
protected TimeKeeper|null $timer from  Timer
protected null|ProgressIndicator $progressIndicator from  ProgressIndicatorAwareTrait
protected array $stack from  StackBasedTask
protected bool $stopOnFail from  StackBasedTask
protected CollectionBuilder $builder from  BuilderAwareTrait
protected Filesystem $fs

Methods

$this
setConfig(ConfigInterface $config)

Set the config management object.

ConfigInterface
getConfig()

Get the config management object.

static string
configPrefix()

Any class that uses ConfigAwareTrait SHOULD override this method , and define a prefix for its configuration items. This is usually done in a base class. When used, this method should return a string that ends with a "."; see BaseTask::configPrefix().

static 
configClassIdentifier($classname)

No description

static 
configPostfix()

No description

static 
configure(string $key, mixed $value, ConfigInterface|null $config = null)

No description

mixed|null
getConfigValue(string $key, mixed|null $default = null)

No description

$this
setVerbosityThreshold(int $verbosityThreshold)

Required verbosity level before any TaskIO output will be produced.

int
verbosityThreshold()

No description

bool
hasOutputAdapter()

No description

writeMessage(string $message)

Print a message if the selected verbosity level is over this task's verbosity threshold.

$this
setOutput(OutputInterface $output)

No description

OutputInterface
output()

No description

OutputInterface
stderr()

No description

OutputInterface
getOutput() deprecated

Backwards compatibility

null|LoggerInterface
logger() deprecated

No description

from  TaskIO
printTaskInfo(string $text, null|array $context = null)

Print information about a task in progress.

from  TaskIO
printTaskSuccess(string $text, null|array $context = null)

Provide notification that some part of the task succeeded.

from  TaskIO
printTaskWarning(string $text, null|array $context = null)

Provide notification that there is something wrong, but execution can continue.

from  TaskIO
printTaskError(string $text, null|array $context = null)

Provide notification that some operation in the task failed, and the task cannot continue.

from  TaskIO
printTaskDebug($text, null|array $context = null)

Provide debugging notification. These messages are only displayed if the log level is VERBOSITY_DEBUG.

from  TaskIO
printTaskOutput(string $level, string $text, null|array $context) deprecated

No description

from  TaskIO
bool
hideTaskProgress()

No description

from  TaskIO
showTaskProgress(bool $inProgress)

No description

from  TaskIO
string
formatBytes(int $size, int $precision = 2)

Format a quantity of bytes.

from  TaskIO
string
getPrintedTaskName(null|object $task = null)

Get the formatted task name for use in task output.

from  TaskIO
array
getTaskContext(null|array $context = null)

No description

from  TaskIO
startTimer()

No description

from  Timer
stopTimer()

No description

from  Timer
resetTimer()

No description

from  Timer
float|null
getExecutionTime()

No description

from  Timer
$this
setProgressIndicator(null|ProgressIndicator $progressIndicator)

No description

null|bool
hideProgressIndicator()

No description

restoreProgressIndicator(bool $visible)

No description

bool
inProgress()

No description

advanceProgressIndicator(int $steps = 1)

No description

$this
inflect(InflectionInterface|mixed $parent)

Ask the provided parent class to inject all of the dependencies that it has and we need.

injectDependencies(mixed $child)

Take all dependencies availble to this task and inject any that are needed into the provided task. The general pattern is that, for every FooAwareInterface that this class implements, it should test to see if the child also implements the same interface, and if so, should call $child->setFoo($this->foo).

from  BaseTask
$this
stopOnFail(bool $stop = true)

No description

null|object
getDelegate()

No description

array
getDelegateCommandList(string $function)

Derived classes that have more than one delegate may override getCommandList to add as many delegate commands as desired to the list of potential functions that __call() tried to find.

printTaskProgress(string $command, string $action)

Print progress about the commands being executed

processResult(int|Result $function_result)

Derived classes can override processResult to add more logic to result handling from functions. By default, it is assumed that if a function returns in int, then 0 == success, and any other value is the error code.

$this
addToCommandStack(string $command, array $args)

Record a function to call later.

$this
__call(string $function, array $args)

Any API function provided by the delegate that executes immediately may be handled by __call automatically. These operations will all be deferred until this task's run() method is called.

run()

Run all of the queued objects on the stack

callTaskMethod(string $command, array $action)

Execute one task method

$this
setBuilder(CollectionBuilder $builder)

No description

__construct()

No description

_copy(string $from, string $to, bool $force = false)

No description

_chmod(string|string[]|Traversable $file, int $permissions, int $umask = 00, bool $recursive = false)

No description

_chgrp(string|string[]|Traversable $file, string $group, bool $recursive = null)

No description

_chown(string|string[]|Traversable $file, string $user, bool $recursive = null)

No description

null|true|Result
_rename(string $origin, string $target, bool $overwrite = false)

No description

null|Result
crossVolumeRename(string $origin, string $target)

No description

$this
mkdir(Traversable $dir, int $mode = 0777)

No description

$this
touch(Traversable $file, int $time = null, int $atime = null)

No description

$this
copy(string $from, string $to, bool $force = false)

No description

$this
chmod(Traversable $file, int $permissions, int $umask = 0000, bool $recursive = false)

No description

$this
chgrp(Traversable $file, string $group, bool $recursive = false)

No description

$this
chown(Traversable $file, string $user, bool $recursive = false)

No description

$this
remove(Traversable $file)

No description

$this
rename(string $from, string $to, bool $force = false)

No description

$this
symlink(string $from, string $to, bool $copyOnWindows = false)

No description

$this
mirror(string $from, string $to, Traversable $iterator = null, array $options = [])

No description

Details

$this setConfig(ConfigInterface $config)

Set the config management object.

Parameters

ConfigInterface $config

Return Value

$this

ConfigInterface getConfig()

Get the config management object.

Return Value

ConfigInterface

static protected string configPrefix()

Any class that uses ConfigAwareTrait SHOULD override this method , and define a prefix for its configuration items. This is usually done in a base class. When used, this method should return a string that ends with a "."; see BaseTask::configPrefix().

Return Value

string

static protected configClassIdentifier($classname)

No description

Parameters

$classname

static protected configPostfix()

No description

static configure(string $key, mixed $value, ConfigInterface|null $config = null)

No description

Parameters

string $key
mixed $value
ConfigInterface|null $config

protected mixed|null getConfigValue(string $key, mixed|null $default = null)

No description

Parameters

string $key
mixed|null $default

Return Value

mixed|null

$this setVerbosityThreshold(int $verbosityThreshold)

Required verbosity level before any TaskIO output will be produced.

e.g. OutputInterface::VERBOSITY_VERBOSE

Parameters

int $verbosityThreshold

Return Value

$this

int verbosityThreshold()

No description

Return Value

int

setOutputAdapter(OutputAdapterInterface $outputAdapter)

No description

Parameters

OutputAdapterInterface $outputAdapter

bool hasOutputAdapter()

No description

Return Value

bool

bool verbosityMeetsThreshold()

No description

Return Value

bool

writeMessage(string $message)

Print a message if the selected verbosity level is over this task's verbosity threshold.

Parameters

string $message

$this setOutput(OutputInterface $output)

No description

Parameters

OutputInterface $output

Return Value

$this

See also

\Robo\Contract\OutputAwareInterface::setOutput()

protected OutputInterface output()

No description

Return Value

OutputInterface

protected OutputInterface stderr()

No description

Return Value

OutputInterface

protected OutputInterface getOutput() deprecated

deprecated

Backwards compatibility

Return Value

OutputInterface

null|LoggerInterface logger() deprecated

deprecated

No description

Return Value

null|LoggerInterface

protected printTaskInfo(string $text, null|array $context = null)

Print information about a task in progress.

With the Symfony Console logger, NOTICE is displayed at VERBOSITY_VERBOSE and INFO is displayed at VERBOSITY_VERY_VERBOSE.

Robo overrides the default such that NOTICE is displayed at VERBOSITY_NORMAL and INFO is displayed at VERBOSITY_VERBOSE.

n.b. We should probably have printTaskNotice for our ordinary output, and use printTaskInfo for less interesting messages.

Parameters

string $text
null|array $context

protected printTaskSuccess(string $text, null|array $context = null)

Provide notification that some part of the task succeeded.

With the Symfony Console logger, success messages are remapped to NOTICE, and displayed in VERBOSITY_VERBOSE. When used with the Robo logger, success messages are displayed at VERBOSITY_NORMAL.

Parameters

string $text
null|array $context

protected printTaskWarning(string $text, null|array $context = null)

Provide notification that there is something wrong, but execution can continue.

Warning messages are displayed at VERBOSITY_NORMAL.

Parameters

string $text
null|array $context

protected printTaskError(string $text, null|array $context = null)

Provide notification that some operation in the task failed, and the task cannot continue.

Error messages are displayed at VERBOSITY_NORMAL.

Parameters

string $text
null|array $context

protected printTaskDebug($text, null|array $context = null)

Provide debugging notification. These messages are only displayed if the log level is VERBOSITY_DEBUG.

Parameters

$text
null|array $context

protected printTaskOutput(string $level, string $text, null|array $context) deprecated

deprecated

No description

Parameters

string $level

One of the \Psr\Log\LogLevel constant

string $text
null|array $context

protected bool hideTaskProgress()

No description

Return Value

bool

protected showTaskProgress(bool $inProgress)

No description

Parameters

bool $inProgress

protected string formatBytes(int $size, int $precision = 2)

Format a quantity of bytes.

Parameters

int $size
int $precision

Return Value

string

protected string getPrintedTaskName(null|object $task = null)

Get the formatted task name for use in task output.

This is placed in the task context under 'name', and used as the log label by Robo\Common\RoboLogStyle, which is inserted at the head of log messages by Robo\Common\CustomLogStyle::formatMessage().

Parameters

null|object $task

Return Value

string

protected array getTaskContext(null|array $context = null)

No description

Parameters

null|array $context

Return Value

array

Context information.

protected startTimer()

No description

protected stopTimer()

No description

protected resetTimer()

No description

protected float|null getExecutionTime()

No description

Return Value

float|null

int progressIndicatorSteps()

No description

Return Value

int

$this setProgressIndicator(null|ProgressIndicator $progressIndicator)

No description

Parameters

null|ProgressIndicator $progressIndicator

Return Value

$this

protected null|bool hideProgressIndicator()

No description

Return Value

null|bool

protected showProgressIndicator()

No description

protected restoreProgressIndicator(bool $visible)

No description

Parameters

bool $visible

protected int getTotalExecutionTime()

No description

Return Value

int

protected startProgressIndicator()

No description

protected bool inProgress()

No description

Return Value

bool

protected stopProgressIndicator()

No description

protected disableProgressIndicator()

No description

protected detatchProgressIndicator()

No description

protected advanceProgressIndicator(int $steps = 1)

No description

Parameters

int $steps

$this inflect(InflectionInterface|mixed $parent)

Ask the provided parent class to inject all of the dependencies that it has and we need.

Parameters

InflectionInterface|mixed $parent

Return Value

$this

injectDependencies(mixed $child)

Take all dependencies availble to this task and inject any that are needed into the provided task. The general pattern is that, for every FooAwareInterface that this class implements, it should test to see if the child also implements the same interface, and if so, should call $child->setFoo($this->foo).

The benefits of this are pretty large. Any time an object that implements InflectionInterface is created, just call $child->inflect($this), and any available optional dependencies will be hooked up via setter injection.

The required dependencies of an object should be provided via constructor injection, not inflection.

Parameters

mixed $child

An object with one or more *AwareInterfaces implemented.

$this stopOnFail(bool $stop = true)

No description

Parameters

bool $stop

Return Value

$this

protected null|object getDelegate()

No description

Return Value

null|object

protected array getDelegateCommandList(string $function)

Derived classes that have more than one delegate may override getCommandList to add as many delegate commands as desired to the list of potential functions that __call() tried to find.

Parameters

string $function

Return Value

array

protected printTaskProgress(string $command, string $action)

Print progress about the commands being executed

Parameters

string $command
string $action

protected Result processResult(int|Result $function_result)

Derived classes can override processResult to add more logic to result handling from functions. By default, it is assumed that if a function returns in int, then 0 == success, and any other value is the error code.

Parameters

int|Result $function_result

Return Value

Result

protected $this addToCommandStack(string $command, array $args)

Record a function to call later.

Parameters

string $command
array $args

Return Value

$this

$this __call(string $function, array $args)

Any API function provided by the delegate that executes immediately may be handled by __call automatically. These operations will all be deferred until this task's run() method is called.

Parameters

string $function
array $args

Return Value

$this

Result run()

Run all of the queued objects on the stack

Return Value

Result

protected Result callTaskMethod(string $command, array $action)

Execute one task method

Parameters

string $command
array $action

Return Value

Result

$this setBuilder(CollectionBuilder $builder)

No description

Parameters

CollectionBuilder $builder

Return Value

$this

See also

BuilderAwareInterface::setBuilder

protected CollectionBuilder collectionBuilder(ConsoleIO $io = null)

No description

Parameters

ConsoleIO $io

Return Value

CollectionBuilder

__construct()

No description

protected _copy(string $from, string $to, bool $force = false)

No description

Parameters

string $from
string $to
bool $force

protected _chmod(string|string[]|Traversable $file, int $permissions, int $umask = 00, bool $recursive = false)

No description

Parameters

string|string[]|Traversable $file
int $permissions
int $umask
bool $recursive

protected _chgrp(string|string[]|Traversable $file, string $group, bool $recursive = null)

No description

Parameters

string|string[]|Traversable $file
string $group
bool $recursive

protected _chown(string|string[]|Traversable $file, string $user, bool $recursive = null)

No description

Parameters

string|string[]|Traversable $file
string $user
bool $recursive

protected null|true|Result _rename(string $origin, string $target, bool $overwrite = false)

No description

Parameters

string $origin
string $target
bool $overwrite

Return Value

null|true|Result

protected null|Result crossVolumeRename(string $origin, string $target)

No description

Parameters

string $origin
string $target

Return Value

null|Result

$this mkdir(Traversable $dir, int $mode = 0777)

No description

Parameters

Traversable $dir
int $mode

Return Value

$this

$this touch(Traversable $file, int $time = null, int $atime = null)

No description

Parameters

Traversable $file
int $time
int $atime

Return Value

$this

$this copy(string $from, string $to, bool $force = false)

No description

Parameters

string $from
string $to
bool $force

Return Value

$this

$this chmod(Traversable $file, int $permissions, int $umask = 0000, bool $recursive = false)

No description

Parameters

Traversable $file
int $permissions
int $umask
bool $recursive

Return Value

$this

$this chgrp(Traversable $file, string $group, bool $recursive = false)

No description

Parameters

Traversable $file
string $group
bool $recursive

Return Value

$this

$this chown(Traversable $file, string $user, bool $recursive = false)

No description

Parameters

Traversable $file
string $user
bool $recursive

Return Value

$this

$this remove(Traversable $file)

No description

Parameters

Traversable $file

Return Value

$this

$this rename(string $from, string $to, bool $force = false)

No description

Parameters

string $from
string $to
bool $force

Return Value

$this

No description

Parameters

string $from
string $to
bool $copyOnWindows

Return Value

$this

$this mirror(string $from, string $to, Traversable $iterator = null, array $options = [])

No description

Parameters

string $from
string $to
Traversable $iterator
array $options

Return Value

$this