The Driver system provides a mechanism to add new drivers for database, configuration storage, and caching to a Silkscreen site.
While the strength of Silkscreen is the ability to enhance a site through the use of modules, an ability inherited from Backdrop and Drupal 7, the Module system requires certain low-level systems to already be active before Silkscreen can tell if an installed module is enabled and active. In the case of a database driver, the list of enabled modules is stored in the system
table, which requires the database code to already be active to see if it should be active. It becomes a chicken-and-egg problem to try to turn these drivers into normal modules.
The Driver system in Silkscreen adds a new driver
directory to the root, core
and sites/sitename
directories. Any driver modules found in these directories are implicitly enabled.
Silkscreen core includes the drivers implemented in Backdrop: BackdropDatabaseCache
, BackdropNullCache
, ConfigFileStorage
, and the MySQL database classes. In addition, core includes the ConfigDatabaseStorage
class.
The driver's .info
file includes additional entries to populate the class autoloader with the location of the driver's class files.
For Configuration Storage drivers, the .info
file must include:
config_backend[classname] = filename.inc
where classname
is the name of a class that implements the ConfigStorageInterface
and filename.inc
is the name of the file that contains the class.
For Database drivers, the .info
file must include multiple lines of the form:
database_backend[classname] = filename.inc
where classname
is the name of a database layer class and filename.inc
is the name of the file that contains the class. Each driver must implement classes that descend from DatabaseConnection
, DatabaseSchema
, and DatabaseTasks
. In addition, most database drivers will require one or more classes that descend from SelectQuery
, InsertQuery
, UpdateQuery
, and TruncateQuery
. Multiple classes can be in the same file, but lines are required for each class.
For Cache drivers, the .info
file must include:
cache_backend[classname] = filename.inc
where classname
is the name of a class that implements the BackdropCacheInterface
and filename.inc
is the name of the file that contains the class.
File names for all drivers are relative to the directory with the driver's .info
file.