Comparing Name to Sections

The issue is the new Configuration Factory, which is that there can be a section and name with the same, well same name. I can check for the name of either for section or name but if both show up then I have an issue, when I need to figure out if they want the name or section. It is easy to figure it out if they are trying to set a name with a value, because they can’t set a section with a value.

I have figured that I could return both the name and the section, but that wouldn’t quite allow the user to access the other subsections. The optimal solution would be to force that either the name or section be unique and offer two functions for checking either one. I should have a third function for checking if there are subsections, which would return just a bool, mostly for the importing and exporting. Each of the subsections would have the same functions allowing for checking in the case the person does not know what values exist or doesn’t remember.

Another part of the classes will be the functions section and name, which could be used in accurately get the sections and names.

$config->section(’section’)->section(’subsection’)->name(‘name’) = value;

which would be the same as

$config['section']['subsection']['name'] = value;

Since the second is less typing then it is all good, except is section is a name, then it will return $config['section'] and nothing else.

XML configuration will be the hardest part about this since there is no restricting this activity or any reason to restrict the activity. How do you tell someone creating a XML document that they can’t have a section and name as the same value? If they have a short file then it would be simple but still pretty damn idiotic (pretty sure they would just laugh). It would be impossible if the file has over 1000 elements.

INI can’t have subsections

…but it can have both sections and names of the same value. Also, names don’t have to be unique either. Which creates an array and returns it. So the scripting would be like

$config->name(‘name’) = value

$config->section(’section’)->name(‘name’) = value

or

$config['name'] = value

$config['section']['name'] = value

Given that most INI or CONF files will have sections that are unique from the names, then the array usage can be acceptable.

Caching

I want to store configuration in arrays when they are used as a sort of caching for values that are going to be used a lot. The only issue is that configuration are mostly used a few times, or at least in my case.

Possibly Related Posts:


Comments are closed.