Commit a6877169 authored by Jon Pugh's avatar Jon Pugh

Add getClassName() method for returning the right class based on type string.

parent 8f32fe5f
......@@ -3,6 +3,7 @@
namespace Aegir\Provision\Command;
use Aegir\Provision\Command;
use Aegir\Provision\Context;
use Aegir\Provision\Context\PlatformContext;
use Aegir\Provision\Context\ServerContext;
use Aegir\Provision\Context\SiteContext;
......@@ -97,7 +98,8 @@ class SaveCommand extends Command
$this->input->setOption('context_type', $context_type);
}
$properties = $this->askForContextProperties();
$context = new ServerContext($input->getArgument('context_name'), $this->getApplication()->getConfig()->all(), $properties);
$class = Context::getClassName($this->input->getOption('context_type'));
$context = new $class($input->getArgument('context_name'), $this->getApplication()->getConfig()->all(), $properties);
}
foreach ($context->getProperties() as $name => $value) {
......
......@@ -140,5 +140,8 @@ class Context
return false;
}
}
static function getClassName($type) {
return '\Aegir\Provision\Context\\' . ucfirst($type) . "Context";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment