Factory

Joomla Platform Factory class.

abstract
since

1.7.0

package

Application

Methods

createConfig

Create a configuration object

createConfig(string file, string type = 'PHP', string namespace = '') : \Joomla\Registry\Registry
static deprecated
see \Joomla\Registry\Registry
since

1.7.0

deprecated

5.0 Use the configuration object within the application.

Arguments

file

stringThe path to the configuration file.

type

stringThe type of the configuration file.

namespace

stringThe namespace of the configuration file.

Response

\Joomla\Registry\Registry

createContainer

Create a container object

createContainer() : \Joomla\DI\Container
static
since

4.0.0

Response

\Joomla\DI\Container

createDbo

Create a database object

createDbo() : \Joomla\Database\DatabaseDriver
static deprecated
see \Joomla\Database\DatabaseDriver
since

1.7.0

deprecated

5.0 Use the database service in the DI container

Response

\Joomla\Database\DatabaseDriver

createDocument

Create a document object

createDocument() : \Joomla\CMS\Document\Document
static deprecated
see Document
since

1.7.0

deprecated

5.0 Load the document service from the dependency injection container or via $app->getDocument()

Response

\Joomla\CMS\Document\Documentobject

createLanguage

Create a language object

createLanguage() : \Joomla\CMS\Language\Language
static deprecated
see Language
since

1.7.0

deprecated

5.0 Load the language service from the dependency injection container or via $app->getLanguage()

Response

\Joomla\CMS\Language\Languageobject

createMailer

Create a mailer object

createMailer() : \Joomla\CMS\Mail\Mail
static
see Mail
since

1.7.0

Response

\Joomla\CMS\Mail\Mailobject

getApplication

Get the global application object. When the global application doesn't exist, an exception is thrown.

getApplication() : \Joomla\CMS\Application\CMSApplicationInterface
static
since

1.7.0

throws

\Exception

Response

\Joomla\CMS\Application\CMSApplicationInterfaceobject

getCache

Get a cache object

getCache(string group = '', string handler = 'callback', string storage = null) : \Joomla\CMS\Cache\CacheController
static deprecated

Returns the global {@link} object

see Cache
since

1.7.0

deprecated

5.0 Use the cache controller factory instead

Arguments

group

stringThe cache group name

handler

stringThe handler to use

storage

stringThe storage method

Response

\Joomla\CMS\Cache\CacheControllerobject

getConfig

Get a configuration object

getConfig(string file = null, string type = 'PHP', string namespace = '') : \Joomla\Registry\Registry
static deprecated

Returns the global {@link} object, only creating it if it doesn't already exist.

see \Joomla\Registry\Registry
since

1.7.0

deprecated

5.0 Use the configuration object within the application.

Arguments

file

stringThe path to the configuration file

type

stringThe type of the configuration file

namespace

stringThe namespace of the configuration file

Response

\Joomla\Registry\Registry

getContainer

Get a container object

getContainer() : \Joomla\DI\Container
static

Returns the global service container object, only creating it if it doesn't already exist.

This method is only suggested for use in code whose responsibility is to create new services and needs to be able to resolve the dependencies, and should therefore only be used when the container is not accessible by other means. Valid uses of this method include:

  • A static getInstance() method calling a factory service from the container, see Joomla\CMS\Toolbar\Toolbar::getInstance() as an example
  • An application front controller loading and executing the Joomla application class, see the cli/joomla.php file as an example
  • Retrieving optional constructor dependencies when not injected into a class during a transitional period to retain backward compatibility, in this case a deprecation notice should also be emitted to notify developers of changes needed in their code

This method is not suggested for use as a one-for-one replacement of static calls, such as replacing calls to Factory::getDbo() with calls to Factory::getContainer()->get('db'), code should be refactored to support dependency injection instead of making this change.

since

4.0.0

Response

\Joomla\DI\Container

getDate

Return the {@link Date} object

getDate(mixed time = 'now', mixed tzOffset = null) : \Joomla\CMS\Date\Date
static
see Date
since

1.7.0

Arguments

time

mixedThe initial time for the Date object

tzOffset

mixedThe timezone offset.

Response

\Joomla\CMS\Date\Dateobject

getDbo

Get a database object.

getDbo() : \Joomla\Database\DatabaseDriver
static deprecated

Returns the global {@link} object, only creating it if it doesn't already exist.

see \Joomla\Database\DatabaseDriver
since

1.7.0

deprecated

5.0 Load the database service from the dependency injection container

Response

\Joomla\Database\DatabaseDriver

getDocument

Get a document object.

getDocument() : \Joomla\CMS\Document\Document
static deprecated

Returns the global {@link} object, only creating it if it doesn't already exist.

see Document
since

1.7.0

deprecated

5.0 Load the document service from the dependency injection container or via $app->getDocument()

Response

\Joomla\CMS\Document\Documentobject

getLanguage

Get a language object.

getLanguage() : \Joomla\CMS\Language\Language
static deprecated

Returns the global {@link} object, only creating it if it doesn't already exist.

see Language
since

1.7.0

deprecated

5.0 Load the language service from the dependency injection container or via $app->getLanguage()

Response

\Joomla\CMS\Language\Languageobject

getMailer

Get a mailer object.

getMailer() : \Joomla\CMS\Mail\Mail
static

Returns the global {@link} object, only creating it if it doesn't already exist.

see Mail
since

1.7.0

Response

\Joomla\CMS\Mail\Mailobject

getSession

Get a session object.

getSession(array options = array()) : \Joomla\CMS\Session\Session
static deprecated

Returns the global {@link} object, only creating it if it doesn't already exist.

see Session
since

1.7.0

deprecated

5.0 Load the session service from the dependency injection container or via $app->getSession()

Arguments

options

arrayAn array containing session options

Response

\Joomla\CMS\Session\Sessionobject

getStream

Creates a new stream object with appropriate prefix

getStream(bool usePrefix = true, bool useNetwork = true, string userAgentSuffix = 'Joomla', bool maskUserAgent = false) : \Joomla\CMS\Filesystem\Stream
static
see Stream
since

1.7.0

Arguments

usePrefix

boolPrefix the connections for writing

useNetwork

boolUse network if available for writing; use false to disable (e.g. FTP, SCP)

userAgentSuffix

stringString to append to user agent

maskUserAgent

boolUser agent masking (prefix Mozilla)

Response

\Joomla\CMS\Filesystem\Stream

getUser

Get a user object.

getUser(int id = null) : \Joomla\CMS\User\User
static deprecated

Returns the global {@link} object, only creating it if it doesn't already exist.

see User
since

1.7.0

deprecated

5.0 Load the user service from the dependency injection container or via $app->getIdentity()

Arguments

id

intThe user to load - Can be an integer or string - If string, it is converted to ID automatically.

Response

\Joomla\CMS\User\Userobject

Properties

application

Global application object

static
since

1.7.0

Type(s)

CMSApplicationInterface

cache

Global cache object

static
since

1.7.0

Type(s)

Cache

config

Global configuration object

static deprecated
since

1.7.0

deprecated

5.0 Use the configuration object within the application

Type(s)

\JConfig

container

Global container object

static
since

4.0.0

Type(s)

\Joomla\DI\Container

dates

Container for Date instances

static
since

1.7.3

Type(s)

array

session

Global session object

static deprecated
since

1.7.0

deprecated

5.0 Use the session service in the DI container

Type(s)

Session

language

Global language object

static deprecated
since

1.7.0

deprecated

5.0 Use the language service in the DI container

Type(s)

Language

document

Global document object

static deprecated
since

1.7.0

deprecated

5.0 Use the document service in the DI container

Type(s)

Document

database

Global database object

static deprecated
since

1.7.0

deprecated

5.0 Use the database service in the DI container

Type(s)

\Joomla\Database\DatabaseDriver

mailer

Global mailer object

static
since

1.7.0

Type(s)

Mail