Remove dispatchFromArray

This commit is contained in:
phecho 2015-12-23 17:44:07 +08:00
parent a4cd04fd11
commit f072f58cb6
2 changed files with 30 additions and 4 deletions

View File

@ -130,8 +130,16 @@ class ComponentController extends Controller
$tags = array_pull($componentData, 'tags');
try {
$componentData['component'] = $component;
$component = $this->dispatchFromArray(UpdateComponentCommand::class, $componentData);
$component = $this->dispatch(new UpdateComponentCommand(
$component,
$componentData['name'],
$componentData['description'],
$componentData['status'],
$componentData['link'],
$componentData['order'],
$componentData['group_id'],
$componentData['enabled']
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.components.edit', ['id' => $component->id])
->withInput(Binput::all())
@ -176,7 +184,15 @@ class ComponentController extends Controller
$tags = array_pull($componentData, 'tags');
try {
$component = $this->dispatchFromArray(AddComponentCommand::class, $componentData);
$component = $this->dispatch(new AddComponentCommand(
$componentData['name'],
$componentData['description'],
$componentData['status'],
$componentData['link'],
$componentData['order'],
$componentData['group_id'],
$componentData['enabled']
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.components.add')
->withInput(Binput::all())

View File

@ -71,8 +71,18 @@ class MetricController extends Controller
*/
public function createMetricAction()
{
$metricData = Binput::get('metric');
try {
$this->dispatchFromArray(AddMetricCommand::class, Binput::get('metric'));
$this->dispatch(new AddMetricCommand(
$metricData['name'],
$metricData['suffix'],
$metricData['description'],
$metricData['default_value'],
$metricData['calc_type'],
$metricData['display_chart'],
$metricData['places']
));
} catch (ValidationException $e) {
return Redirect::route('dashboard.metrics.add')
->withInput(Binput::all())