IObjectFactory

Artaengine object factory interface. In an Artaengine app the most efficient and appropriate way to create/get-handle to objects which access a resource such as a database connection, cache, template engine, etc. is to use the object factory provided for it, this factories must implement this interface. Each object is identified by a name(object-name) and can have configs. The object name and configs can be set in the app config array or ini file.
Source
IObjectFactory.php
Implementations
Cache , Database , Log , Template

Static Methods

config

array|string IObjectFactory::config(
    string objectName=null,
    string index=null,
    array configs=null
)

Set or get configs for a an object.

Arguments

    objectName=null (string)
    The object name to set or to get configs for, null=return all object configs
    index=null (string)
    Config key, to get the value of a specific setting
    configs=null (array)
    To add new object config params

Returns

array|string
{configs} or {object-name: {configs},} or the value of a config key

get

object|array IObjectFactory::get(string | bool objectName=null, bool remove=false)

Creates and returns or returns an already created object.

Arguments

    objectName=null (string | bool)
    Object name to create or to get handle of, null=return the last object in the list, true=return all objects
    remove=false (bool)
    true=remove/unsset the object

Returns

object|array
Reference to the object(s)

getCreateNew

object IObjectFactory::getCreateNew(string objectName, array configs)

Creates and returns an object.

Arguments

    objectName (string)
    The object name to be created
    configs (array)
    Database connection/object configs
    {
        string engine   : database engine name e.g. PostgreSQL, MySQL,
        string server   : localhost database server address,
        string port     : depends on the engine database server port,
        string dbname   : database name,
        string user     : database user-name,
        string password : database password,
        string advanced : false
            false=create an IDbAbstract instance
            true=create an IDbAdvanced instance,
    }
    

Returns

object
Reference to the newly created object

remove

void IObjectFactory::remove(string objectName)

Remove an object if already been created.

Arguments

    objectName (string)
    Object name to remove

Returns

void