I have created a custom service which creates custom fields in the customer form during plugin installation. When activating the plugin, the service runs correctly and performs the required function.
public function activate(ActivateContext $context): void
{
../
$customFieldSetService = $this->container->get('custom.service');
$customFieldSetService->extendCustomerFields();
/..
}
When uninstalling the plugin, I get the error message: You have requested a non-existent service "custom.service".
public function uninstall(UninstallContext $context): void
{
../
$customFieldSetService = $this->container->get('custom.service');
$customFieldSetService->deleteCustomerFields();
/..
}
service.xml:
<service id="custom.service" class="MyPlugin\Service\CustomFieldSetService" public="true" />
How can I call my own service within the uninstall function?