Tag syncing is now done within the Component commands
This commit is contained in:
@@ -113,7 +113,6 @@ class ComponentController extends Controller
|
||||
public function updateComponentAction(Component $component)
|
||||
{
|
||||
$componentData = Binput::get('component');
|
||||
$tags = Arr::pull($componentData, 'tags');
|
||||
|
||||
try {
|
||||
$component = execute(new UpdateComponentCommand(
|
||||
@@ -126,6 +125,7 @@ class ComponentController extends Controller
|
||||
$componentData['group_id'],
|
||||
$componentData['enabled'],
|
||||
null, // Meta data cannot be supplied through the dashboard yet.
|
||||
$componentData['tags'], // Meta data cannot be supplied through the dashboard yet.
|
||||
true // Silent since we're not really making changes to the component (this should be optional)
|
||||
));
|
||||
} catch (ValidationException $e) {
|
||||
@@ -135,17 +135,6 @@ class ComponentController extends Controller
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$component->tags()->delete();
|
||||
|
||||
// The component was added successfully, so now let's deal with the tags.
|
||||
Collection::make(preg_split('/ ?, ?/', $tags))->map(function ($tag) {
|
||||
return trim($tag);
|
||||
})->map(function ($tag) {
|
||||
return execute(new CreateTagCommand($tag));
|
||||
})->each(function ($tag) use ($component) {
|
||||
execute(new ApplyTagCommand($component, $tag));
|
||||
});
|
||||
|
||||
return cachet_redirect('dashboard.components.edit', [$component->id])
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success')));
|
||||
}
|
||||
@@ -170,7 +159,6 @@ class ComponentController extends Controller
|
||||
public function createComponentAction()
|
||||
{
|
||||
$componentData = Binput::get('component');
|
||||
$tags = Arr::pull($componentData, 'tags');
|
||||
|
||||
try {
|
||||
$component = execute(new CreateComponentCommand(
|
||||
@@ -181,7 +169,8 @@ class ComponentController extends Controller
|
||||
$componentData['order'],
|
||||
$componentData['group_id'],
|
||||
$componentData['enabled'],
|
||||
null // Meta data cannot be supplied through the dashboard yet.
|
||||
null, // Meta data cannot be supplied through the dashboard yet.
|
||||
$componentData['tags']
|
||||
));
|
||||
} catch (ValidationException $e) {
|
||||
return cachet_redirect('dashboard.components.create')
|
||||
@@ -190,15 +179,6 @@ class ComponentController extends Controller
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
// The component was added successfully, so now let's deal with the tags.
|
||||
Collection::make(preg_split('/ ?, ?/', $tags))->map(function ($tag) {
|
||||
return trim($tag);
|
||||
})->map(function ($tag) {
|
||||
return execute(new CreateTagCommand($tag));
|
||||
})->each(function ($tag) use ($component) {
|
||||
execute(new ApplyTagCommand($component, $tag));
|
||||
});
|
||||
|
||||
return cachet_redirect('dashboard.components')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.add.success')));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user