mirror of
https://github.com/hauke68/Magallanes.git
synced 2025-09-17 14:20:18 +02:00
More generic way to handle command line options
This commit is contained in:
parent
979a86992c
commit
ffdadb45cf
@ -113,18 +113,17 @@ class PermissionsTask extends AbstractTask
|
|||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$command = '';
|
$command = '';
|
||||||
$recursive = $this->recursive ? '-R' : '';
|
|
||||||
|
|
||||||
if ($this->paths && $this->owner) {
|
if ($this->paths && $this->owner) {
|
||||||
$command .= 'chown '. $recursive .' ' . $this->owner . ' ' . $this->getPathsForCmd() . ';';
|
$command .= 'chown '. $this->getOptionsForCmd() .' ' . $this->owner . ' ' . $this->getPathsForCmd() . ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->paths && $this->group) {
|
if ($this->paths && $this->group) {
|
||||||
$command .= 'chgrp '. $recursive .' ' . $this->group . ' ' . $this->getPathsForCmd() . ';';
|
$command .= 'chgrp '. $this->getOptionsForCmd() .' ' . $this->group . ' ' . $this->getPathsForCmd() . ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->paths && $this->rights) {
|
if ($this->paths && $this->rights) {
|
||||||
$command .= 'chmod '. $recursive .' ' . $this->rights . ' ' . $this->getPathsForCmd() . ';';
|
$command .= 'chmod '. $this->getOptionsForCmd() .' ' . $this->rights . ' ' . $this->getPathsForCmd() . ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->runCommand($command);
|
$result = $this->runCommand($command);
|
||||||
@ -132,6 +131,27 @@ class PermissionsTask extends AbstractTask
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the options for the commands to run. Only supports -R for now.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getOptionsForCmd()
|
||||||
|
{
|
||||||
|
$optionsForCmd = '';
|
||||||
|
$options = array(
|
||||||
|
'R' => $this->recursive
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach($options as $option => $apply) {
|
||||||
|
if ($apply == true) {
|
||||||
|
$optionsForCmd .= $option;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $optionsForCmd ? '-' . $optionsForCmd : '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms paths array to a string separated by 1 space in order to use
|
* Transforms paths array to a string separated by 1 space in order to use
|
||||||
* it in a command line.
|
* it in a command line.
|
||||||
|
Loading…
Reference in New Issue
Block a user