phemellc / yii2-settings

Yii2 Settings Module
Other
151 stars 74 forks source link

implemented has method #46

Closed schmunk42 closed 8 years ago

schmunk42 commented 8 years ago

This is related to https://github.com/phemellc/yii2-settings/issues/37#issuecomment-182534510

Note! This is implemented in an uncached version, which is not ideal. But I ran into some complications, because I'd need to cache "all" values instead "active" (current default). This also applies to _data which would also have to distinguish between "all" and "active".

Let me know your thoughts.

Btw: Is it by design that a key can exist twice?

arisk commented 8 years ago

How about if we implement has as a single query that fetches 1 value and just forgo caching in that case? Probably also make searching for disabled settings an optional param? It is by design. A combination of section and key should form a unique value.

schmunk42 commented 8 years ago

It is by design. A combination of section and key should form a unique value.

Nice 👍 I misunderstood it first, I think.

Probably also make searching for disabled settings an optional param?

That's absolutely necessary.

How about if we implement has as a single query that fetches 1 value and just forgo caching in that case?

I would cache has() also, may also be called very often.

How about caching the whole settings and use has() in get()?

arisk commented 8 years ago

You're right. Probably the best idea is to use get to implement has. That way we inherit the caching functionality. The only consequence is that we will have to return all items including disabled items in getSettings(). So the settings array will actually have to hold a flag as to wether the item is disabled or not.

schmunk42 commented 8 years ago

Any thoughts about adding some tests by the way?

arisk commented 8 years ago

Sure. Definitely need unit tests for the component. I'll try to find time to add some tests pretty soon. On Apr 18, 2016 7:29 PM, "Tobias Munk" notifications@github.com wrote:

Any thoughts about adding some tests by the way?

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/phemellc/yii2-settings/pull/46#issuecomment-211358336