Bugfixes and improvements to shell and context
This commit is contained in:
@ -12,6 +12,9 @@ class Context
|
||||
|
||||
protected $data = [];
|
||||
|
||||
protected $parent;
|
||||
|
||||
protected $shell;
|
||||
|
||||
public function __construct($name=null, array $data=[])
|
||||
{
|
||||
@ -20,6 +23,28 @@ class Context
|
||||
$this->configure();
|
||||
}
|
||||
|
||||
public function setParent(Context $parent=null)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function getRoot()
|
||||
{
|
||||
if (!$this->parent) {
|
||||
return $this;
|
||||
}
|
||||
$node = $this;
|
||||
while ($parent = $node->getParent()) {
|
||||
$node = $parent;
|
||||
}
|
||||
return $parent;
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
// Override this to do setup stuff
|
||||
@ -52,6 +77,7 @@ class Context
|
||||
{
|
||||
$this->commands[$command] = $handler;
|
||||
$this->commandInfo[$command] = $info;
|
||||
ksort($this->commands);
|
||||
}
|
||||
|
||||
public function setCommandHelp($command, $help)
|
||||
|
Reference in New Issue
Block a user