Answer the question
In order to leave comments, you need to log in
What is the best way to implement enabling and disabling functionality?
I have features, 1,2,3,4... however they are still at the testing stage and I want to disable them for the time being in production.
After testing, debugging, etc. upload to production, however, if something goes wrong, be able to turn off this functionality and block access to it. Let's say to issue a page that this feature is temporarily disabled. Quickly fix everything, upload it to the stage, then after the tests in production, and change the checkbox to indicate that the feature is enabled. As with the light in the room.
Has anyone already done this? Any ideas how to do it better?
Answer the question
In order to leave comments, you need to log in
It all depends on the architecture of your application, the presence of a front-end framework and other conditions.
But at the heart of the solution, in a good way, should be a system of access rights or display conditions, configured through the admin panel.
In React , I would write a PermissionChecker component that would check the permission keys written to the html template in window.__data . twig example :
<script>
window.__data = {
permissions: {{ permissions|json_encode|raw }}
};
</script>
export const routes = [
{
path: '/feature1',
component: feature1,
requiredPermissions: PERMISSIONS.FEATURE_1,
},
...
]
render() {
return(
<Wrapper>
...
<PermissionChecker
requiredPermissions={PERMISSIONS.FEATURE_2}
>
<Feature2 />
</PermissionChecker>
</Wrapper>
);
}
Once upon a time, I implemented a module system in such a way that one module is one plug-in file (in my case, php), when connected, the file is registered where necessary, adding the necessary items to the menu and buttons.
Accordingly, simply disabling include completely turned off the functionality.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question