Configuration Data Store Class

In an inspiration on how I’m going to create the generic Configuration Factory, I decided that I should create a Data Store for the configuration with a reference back to the creation class. In this way, I can reference all of the features, restrictions, nonunique names and sections, and provide a way for creating more than the three possible configurations later.

This would require I refactor the configuration class yet again, but seeing as I didn’t quite finish the SQLite part, it wouldn’t be a huge loss. It would however get into another complex class model, but it would keep from rewriting a lot of the same code over and over again.

Three base Configuration classes:

  1. ConfigurationSQLite
  2. ConfigurationXML
  3. ConfigurationConf : Which will also load INI and TXT files.

There will also be a few other classes for the DataStore:

  • ConfigurationDataStore
  • ConfigurationName
  • ConfigurationSection
  • ConfigurationVisibility
  • ConfigurationRestrictions

Example

The DataStore class will hold the Name, Section, Visibility, and Restrictions classes and provide access to them. If there are nonunique names and sections, then an array will be returned that will reference the name and section.

$config['database'] //is not unique, there is also a section with the same name.

$config['database']['name'] //name is not the variable and will not change. Will return the database name value.

$config['database']['section'] // Will return the section.

So, if Database has a subsection, then this would have to be done.

$config['database']['section']['connections']['section']

It will also be possible to do:

$config['database']->getName(); // Will return the name value for Database instead of returning the Section.
$config['database']['connections']

If you want to use that name get method instead. However the name will be the only method that will do this. if they want to do with sections they would have to use the sections method from the beginning.

Reasoning

I want to have a lot of different configurations for the Configuration Factory in case the person wants or needs to return the name on default.

The best case is when the programmer is creating the configuration from the base using the Configuration Class to do so. In which way, they would be able to create it to where there are no unique values. However in an environment where the configuration is external that is not always possible and such a restriction can not be put in place.

Possibly Related Posts:


Comments are closed.