Is there a way to protect specific properties and ...
# cfml-general
d
Is there a way to protect specific properties and still have implicit getter/setter available?
Copy code
component accessors=true {
  private property name="settings"; // <-- do not allow setter/getter publicly
  property name="a"; // this is ok publicly
}
b
Does settings need to be a property?
If you don’t need public set/get, could it just be in the component variables scope?
d
thats how I initially created it and I used the setter and getter for it. but then i used the setter from another cfc and caught myself. I should protect it.
it can be in variables
I also just wanted the implicit getter setter for it too.
b
what’s the advantage of having the set/get for the internal component use?
d
well I guess there isn't any. I'm just used to using getSettings() and setSettings( ... ) instead of just
settings = ...
b
Yeah I feel you on that, I was just curious
b
Personally I use a property for everything and I just don't worry too much about the fact that the accessor is public. 🙂
👍🏾 1
d
thats I went with
e
I would wrap your queries, methods, and other objects you are worried about with encryption if you want security. Yes, it could be your box, and yes your code is secure as hell, but why not add some extra icing to the cake and add a token checker to the call.
c
Copy code
component accessors=true {
  property name="settings" setter=false getter=false; // <-- do not allow setter/getter publicly
  property name="a"; // this is ok publicly
}
🧐 1
d
I should have tried that. I thought those attributes would also remove the implicit getter/setter within the cfc. Coding...
getter=false setter=false
also removes them within the CFC. I want implicit getter/setter within the cfc but not publicly. Either way, its not a show stopper. I was just curious.
c
Sorry, didn't read the thread carefully enough. But that's what I would use to protect the
settings
property, and then use
variables.settings
internally.
👍🏾 1
d
yeah exactly.