Tag syncing is now done within the Component commands
This commit is contained in:
@@ -84,25 +84,13 @@ class ComponentController extends AbstractApiController
|
||||
Binput::get('order'),
|
||||
Binput::get('group_id'),
|
||||
(bool) Binput::get('enabled', true),
|
||||
Binput::get('meta', null)
|
||||
Binput::get('meta'),
|
||||
Binput::get('tags'),
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
if (Binput::has('tags')) {
|
||||
$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 $this->item($component);
|
||||
}
|
||||
|
||||
@@ -125,26 +113,14 @@ class ComponentController extends AbstractApiController
|
||||
Binput::get('order'),
|
||||
Binput::get('group_id'),
|
||||
Binput::get('enabled', $component->enabled),
|
||||
Binput::get('meta', null),
|
||||
Binput::get('meta'),
|
||||
Binput::get('tags'),
|
||||
(bool) Binput::get('silent', false)
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
if (Binput::has('tags')) {
|
||||
$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 $this->item($component);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user